Skip to content

Commit 94c5034

Browse files
committed
Auto merge of #17150 - RalfJung:josh-pull, r=lnicola
internal: add no-new-root check to josh pull We probably don't want a second root to show up... Also clear the rust-version file while we are at it.
2 parents 0d33960 + 70fb039 commit 94c5034

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/tools/rust-analyzer/rust-version

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
688c30dc9f8434d63bddb65bd6a4d2258d19717c

src/tools/rust-analyzer/xtask/src/release.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ impl flags::RustcPull {
9595
if !cmd!(sh, "git status --untracked-files=no --porcelain").read()?.is_empty() {
9696
bail!("working directory must be clean before running `cargo xtask pull`");
9797
}
98+
// This should not add any new root commits. So count those before and after merging.
99+
let num_roots = || -> anyhow::Result<u32> {
100+
Ok(cmd!(sh, "git rev-list HEAD --max-parents=0 --count")
101+
.read()
102+
.context("failed to determine the number of root commits")?
103+
.parse::<u32>()?)
104+
};
105+
let num_roots_before = num_roots()?;
98106
// Make sure josh is running.
99107
let josh = start_josh()?;
100108

@@ -126,6 +134,11 @@ impl flags::RustcPull {
126134
.run()
127135
.context("FAILED to merge new commits, something went wrong")?;
128136

137+
// Check that the number of roots did not increase.
138+
if num_roots()? != num_roots_before {
139+
bail!("Josh created a new root commit. This is probably not the history you want.");
140+
}
141+
129142
drop(josh);
130143
Ok(())
131144
}

0 commit comments

Comments
 (0)