@@ -180,7 +180,17 @@ fn get_git_root() -> PathBuf {
180
180
181
181
/// Return the commit range, or panic
182
182
fn commit_range ( ) -> String {
183
- env:: var ( "COMMIT_RANGE" ) . unwrap ( )
183
+ // Use the env var, if set. E.g. COMMIT_RANGE='HEAD~n..HEAD' for the last 'n' commits.
184
+ env:: var ( "COMMIT_RANGE" ) . unwrap_or_else ( |_| {
185
+ // Otherwise, assume that a merge commit exists. This merge commit is assumed
186
+ // to be the base, after which linting will be done. If the merge commit is
187
+ // HEAD, the range will be empty.
188
+ format ! (
189
+ "{}..HEAD" ,
190
+ check_output( git( ) . args( [ "rev-list" , "--max-count=1" , "--merges" , "HEAD" ] ) )
191
+ . expect( "check_output failed" )
192
+ )
193
+ } )
184
194
}
185
195
186
196
/// Return all subtree paths
@@ -673,6 +683,10 @@ fn main() -> ExitCode {
673
683
} ;
674
684
675
685
let git_root = get_git_root ( ) ;
686
+ let commit_range = commit_range ( ) ;
687
+ let commit_log = check_output ( git ( ) . args ( [ "log" , "--no-merges" , "--oneline" , & commit_range] ) )
688
+ . expect ( "check_output failed" ) ;
689
+ println ! ( "Checking commit range ({commit_range}):\n {commit_log}\n " ) ;
676
690
677
691
let mut test_failed = false ;
678
692
for linter in linters_to_run {
0 commit comments