File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
- 688c30dc9f8434d63bddb65bd6a4d2258d19717c
Original file line number Diff line number Diff line change @@ -95,6 +95,14 @@ impl flags::RustcPull {
95
95
if !cmd ! ( sh, "git status --untracked-files=no --porcelain" ) . read ( ) ?. is_empty ( ) {
96
96
bail ! ( "working directory must be clean before running `cargo xtask pull`" ) ;
97
97
}
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 ( ) ?;
98
106
// Make sure josh is running.
99
107
let josh = start_josh ( ) ?;
100
108
@@ -126,6 +134,11 @@ impl flags::RustcPull {
126
134
. run ( )
127
135
. context ( "FAILED to merge new commits, something went wrong" ) ?;
128
136
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
+
129
142
drop ( josh) ;
130
143
Ok ( ( ) )
131
144
}
You can’t perform that action at this time.
0 commit comments