Skip to content

Commit ffe422b

Browse files
authored
Merge pull request #392 from Kobzol/remove-master-dependency
Remove hardcoded dependency on master
2 parents 3f2731a + e7aaa6b commit ffe422b

File tree

8 files changed

+19
-26
lines changed

8 files changed

+19
-26
lines changed

guide/src/alt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ You will need to specify `--by-commit` (or use a hash in the `--start` or `--end
2424
cargo bisect-rustc --alt --by-commit
2525
```
2626

27-
[`config.toml` docs]: https://github.com/rust-lang/rust/blob/master/config.example.toml
27+
[`config.toml` docs]: https://github.com/rust-lang/rust/blob/HEAD/config.example.toml
2828
[`ci/run.sh`]: https://github.com/rust-lang/rust/blob/c0b6ffaaea3ebdf5f7a58fc4cf7ee52c91077fb9/src/ci/run.sh#L99-L105
2929
[`ci.yml`]: https://github.com/rust-lang/rust/blob/HEAD/src/ci/github-actions/ci.yml

guide/src/boundaries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ cargo bisect-rustc \
4545

4646
There are several ways to determine the SHA-1 hash for a PR.
4747

48-
- On the PR itself, you should see a message like "bors merged commit c50c62d into `rust-lang:master`".
48+
- On the PR itself, you should see a message like "bors merged commit c50c62d into `rust-lang:<default-branch>`".
4949
You can copy that hash to use as a boundary.
5050
If the PR was merged as part of a rollup, you will need to use the hash of the rollup instead.
5151
You'll need to look through the PR messages to see if the PR was mentioned from a rollup PR.
52-
- In the rust repo, run `git log --first-parent upstream/master` (where `upstream` is your origin name for `rust-lang/rust`).
52+
- In the rust repo, run `git log --first-parent upstream/HEAD` (where `upstream` is your origin name for `rust-lang/rust`).
5353
This will show all the top-level commits.
5454
You can then search for your PR.
5555

guide/src/git-bisect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
There are some rare cases where you may need to build `rustc` with custom options, or otherwise work around issues with pre-built compilers not being available.
44
For this you can use [`git bisect`] to build the compiler locally.
55

6-
It can be helpful to use the `--first-parent` option so that it only bisects the merge commits directly reachable on the master branch.
6+
It can be helpful to use the `--first-parent` option so that it only bisects the merge commits directly reachable on the default branch.
77
Otherwise the bisecting may land on intermediate commits from within a PR which may not build or test correctly.
88

99
To start the bisection, specifying the boundaries where the bisection will start:

src/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Bounds {
9393
}
9494
(Some(Bound::Commit(start)), None) => Bounds::Commits {
9595
start,
96-
end: args.access.repo().commit("origin/master")?.sha,
96+
end: args.access.repo().commit("HEAD")?.sha,
9797
},
9898
(None, Some(Bound::Commit(end))) => Bounds::Commits {
9999
start: EPOCH_COMMIT.to_string(),

src/git.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,19 @@ impl Deref for RustcRepo {
5252
fn lookup_rev<'rev>(repo: &'rev RustcRepo, rev: &str) -> anyhow::Result<Git2Commit<'rev>> {
5353
let revision = repo.revparse_single(rev)?;
5454

55-
// Find the merge-base between the revision and master.
56-
// If revision is a normal commit contained in master, the merge-base will be the commit itself.
57-
// If revision is a tag (e.g. a release version), the merge-base will contain the latest master
58-
// commit contained in that tag.
59-
let master_id = repo
60-
.revparse_single(&format!("{}/master", repo.origin_remote))?
55+
// Find the merge-base between the revision and the default branch.
56+
// If revision is a normal commit contained in the default branch, the merge-base will be the
57+
// commit itself.
58+
// If revision is a tag (e.g. a release version), the merge-base will contain the latest
59+
// default branch commit contained in that tag.
60+
let default_branch_id = repo
61+
.revparse_single(&format!("{}/HEAD", repo.origin_remote))?
6162
.id();
6263
let revision_id = revision
6364
.as_tag()
6465
.map_or_else(|| revision.id(), git2::Tag::target_id);
6566

66-
let common_base = repo.merge_base(master_id, revision_id)?;
67+
let common_base = repo.merge_base(default_branch_id, revision_id)?;
6768

6869
if let Ok(c) = repo.find_commit(common_base) {
6970
return Ok(c);
@@ -155,7 +156,7 @@ pub fn get_commits_between(first_commit: &str, last_commit: &str) -> anyhow::Res
155156
Some(author) if author == BORS_AUTHOR => Ok(()),
156157
Some(author) => bail!(
157158
"Expected author {author} to be {BORS_AUTHOR} for {}.\n \
158-
Make sure specified commits are on the master branch!",
159+
Make sure specified commits are on the default branch!",
159160
c.id()
160161
),
161162
None => bail!("No author for {}", c.id()),

src/github.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,8 @@ impl ToUrl for CommitsUrl<'_> {
224224

225225
impl ToUrl for CommitDetailsUrl<'_> {
226226
fn url(&self) -> String {
227-
// "origin/master" is set as `sha` when there is no `--end=` definition
228-
// specified on the command line. We define the GitHub master branch
229-
// HEAD commit as the end commit in this case
230-
let reference = if self.sha == "origin/master" {
231-
"master"
232-
} else {
233-
self.sha
234-
};
235-
236-
format!("https://api.github.com/repos/{OWNER}/{REPO}/compare/master...{reference}")
227+
let reference = self.sha;
228+
format!("https://api.github.com/repos/{OWNER}/{REPO}/compare/HEAD...{reference}")
237229
}
238230
}
239231

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ impl Config {
10001000
if c.committer.name != BORS_AUTHOR {
10011001
bail!(
10021002
"Expected author {} to be {BORS_AUTHOR} for {}.\n \
1003-
Make sure specified commits are on the master branch \
1003+
Make sure specified commits are on the default branch \
10041004
and refer to a bors merge commit!",
10051005
c.committer.name,
10061006
c.sha

src/repo_access.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) trait RustRepositoryAccessor {
1212
}
1313

1414
/// Looks up commit associated with `commit_ref`, which can be either a sha
15-
/// or a more general reference like "origin/master".
15+
/// or a more general reference like "origin/HEAD".
1616
/// If `commit_ref` is a commit forked from the "mainline" git history
1717
/// (e.g. a stable tag like `1.88.0`), returns the merge base of the given commit reference.
1818
fn commit(&self, commit_ref: &str) -> anyhow::Result<Commit>;
@@ -33,7 +33,7 @@ impl RustRepositoryAccessor for AccessViaLocalGit {
3333
git::get_commit(commit_ref)
3434
}
3535
fn commits(&self, start_sha: &str, end_sha: &str) -> anyhow::Result<Vec<Commit>> {
36-
let end_sha = if end_sha == "origin/master" {
36+
let end_sha = if end_sha == "HEAD" {
3737
"FETCH_HEAD"
3838
} else {
3939
end_sha

0 commit comments

Comments
 (0)