diff options
| author | Ralf Jung <post@ralfj.de> | 2024-04-27 09:02:07 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-04-27 09:02:07 +0200 |
| commit | 0274d34f7519af255900ae97feaa60dd4183ddae (patch) | |
| tree | 697ea1887b1e91d1373615042d72ede6b81ac541 | |
| parent | a200391f54d44e05ef20c1b65bb206deeece24bd (diff) | |
| download | rust-0274d34f7519af255900ae97feaa60dd4183ddae.tar.gz rust-0274d34f7519af255900ae97feaa60dd4183ddae.zip | |
add no-new-root check to josh pull
| -rw-r--r-- | src/tools/rust-analyzer/xtask/src/release.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/xtask/src/release.rs b/src/tools/rust-analyzer/xtask/src/release.rs index 9dcf7af00bf..5699053a23d 100644 --- a/src/tools/rust-analyzer/xtask/src/release.rs +++ b/src/tools/rust-analyzer/xtask/src/release.rs @@ -95,6 +95,14 @@ impl flags::RustcPull { if !cmd!(sh, "git status --untracked-files=no --porcelain").read()?.is_empty() { bail!("working directory must be clean before running `cargo xtask pull`"); } + // This should not add any new root commits. So count those before and after merging. + let num_roots = || -> anyhow::Result<u32> { + Ok(cmd!(sh, "git rev-list HEAD --max-parents=0 --count") + .read() + .context("failed to determine the number of root commits")? + .parse::<u32>()?) + }; + let num_roots_before = num_roots()?; // Make sure josh is running. let josh = start_josh()?; @@ -126,6 +134,11 @@ impl flags::RustcPull { .run() .context("FAILED to merge new commits, something went wrong")?; + // Check that the number of roots did not increase. + if num_roots()? != num_roots_before { + bail!("Josh created a new root commit. This is probably not the history you want."); + } + drop(josh); Ok(()) } |
