Skip to content

Commit

Permalink
Auto merge of rust-lang#3520 - RalfJung:josh-check, r=RalfJung
Browse files Browse the repository at this point in the history
josh rustc-pull: check that no new root commits get created

A second root was a bad sign in Miri (judging from the description in rust-lang/miri#2583) and seems to be a [bad sign in RA](rust-lang/rust-analyzer#17025 (comment)). So let's add this to the sanity checks.
  • Loading branch information
bors committed Apr 27, 2024
2 parents f5ceb4e + 2681edf commit 45d9394
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,26 @@ impl Command {
})
.context("FAILED to fetch new commits, something went wrong (committing the rust-version file has been undone)")?;

// This should not add any new root commits. So count those before and after merging.
let num_roots = || -> 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()?;

// Merge the fetched commit.
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
.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(())
}
Expand Down

0 comments on commit 45d9394

Please sign in to comment.