Skip to content

Commit 0274d34

Browse files
committed
add no-new-root check to josh pull
1 parent a200391 commit 0274d34

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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)