File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments