Skip to content

Commit 95e8b86

Browse files
committed
Auto merge of #99149 - ferrocene:pa-nightly-branch, r=Mark-Simulacrum
Configure nightly branch name in `stage0.json` The beta version number detection code relies on git to know how many merge commits were made since we branched off, and in doing so hardcodes `master` as the default branch name. This works for rust-lang/rust, but is problematic for forks that use a different default branch name (in Ferrocene we use `main` instead). This PR changes the code to instead load the default branch name from `src/stage0.json`. `bump-stage0` has also been updated to remove the need to update it every time a new field is added to `stage0.json`.
2 parents 7b57152 + 6bc97d0 commit 95e8b86

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

src/bootstrap/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ pub struct Stage0Config {
226226
pub artifacts_server: String,
227227
pub artifacts_with_llvm_assertions_server: String,
228228
pub git_merge_commit_email: String,
229+
pub nightly_branch: String,
229230
}
230231
#[derive(Default, Deserialize)]
231232
#[cfg_attr(test, derive(Clone))]

src/bootstrap/lib.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1280,14 +1280,11 @@ impl Build {
12801280
// Figure out how many merge commits happened since we branched off master.
12811281
// That's our beta number!
12821282
// (Note that we use a `..` range, not the `...` symmetric difference.)
1283-
let count = output(
1284-
self.config
1285-
.git()
1286-
.arg("rev-list")
1287-
.arg("--count")
1288-
.arg("--merges")
1289-
.arg("refs/remotes/origin/master..HEAD"),
1290-
);
1283+
let count =
1284+
output(self.config.git().arg("rev-list").arg("--count").arg("--merges").arg(format!(
1285+
"refs/remotes/origin/{}..HEAD",
1286+
self.config.stage0_metadata.config.nightly_branch
1287+
)));
12911288
let n = count.trim().parse().unwrap();
12921289
self.prerelease_version.set(Some(n));
12931290
n

src/stage0.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"dist_server": "https://static.rust-lang.org",
44
"artifacts_server": "https://ci-artifacts.rust-lang.org/rustc-builds",
55
"artifacts_with_llvm_assertions_server": "https://ci-artifacts.rust-lang.org/rustc-builds-alt",
6-
"git_merge_commit_email": "[email protected]"
6+
"git_merge_commit_email": "[email protected]",
7+
"nightly_branch": "master"
78
},
89
"__comments": [
910
"The configuration above this comment is editable, and can be changed",

src/tools/bump-stage0/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ anyhow = "1.0.34"
1010
curl = "0.4.38"
1111
indexmap = { version = "1.7.0", features = ["serde"] }
1212
serde = { version = "1.0.125", features = ["derive"] }
13-
serde_json = "1.0.59"
13+
serde_json = { version = "1.0.59", features = ["preserve_order"] }
1414
toml = "0.5.7"

src/tools/bump-stage0/src/main.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,12 @@ struct Stage0 {
198198
#[derive(Debug, serde::Serialize, serde::Deserialize)]
199199
struct Config {
200200
dist_server: String,
201-
artifacts_server: String,
202-
artifacts_with_llvm_assertions_server: String,
203-
git_merge_commit_email: String,
201+
// There are other fields in the configuration, which will be read by src/bootstrap or other
202+
// tools consuming stage0.json. To avoid the need to update bump-stage0 every time a new field
203+
// is added, we collect all the fields in an untyped Value and serialize them back with the
204+
// same order and structure they were deserialized in.
205+
#[serde(flatten)]
206+
other: serde_json::Value,
204207
}
205208

206209
#[derive(Debug, serde::Serialize, serde::Deserialize)]

0 commit comments

Comments
 (0)