@@ -2725,31 +2725,18 @@ impl Config {
27252725 crate :: exit!( 1 ) ;
27262726 }
27272727
2728- // Warn if there were changes to the compiler or standard library since the ancestor commit.
2729- let has_changes = !t ! ( helpers:: git( Some ( & self . src) )
2730- . args( [ "diff-index" , "--quiet" , & commit] )
2731- . arg( "--" )
2732- . args( [ self . src. join( "compiler" ) , self . src. join( "library" ) ] )
2733- . as_command_mut( )
2734- . status( ) )
2735- . success ( ) ;
2736- if has_changes {
2737- if if_unchanged {
2738- if self . verbose > 0 {
2739- println ! (
2740- "WARNING: saw changes to compiler/ or library/ since {commit}; \
2741- ignoring `download-rustc`"
2742- ) ;
2743- }
2744- return None ;
2728+ let dirs = vec ! [ PathBuf :: from( "compiler" ) , PathBuf :: from( "library" ) ] ;
2729+ match self . check_for_changes ( & dirs, & commit, "download-rustc" , if_unchanged) {
2730+ Some ( true ) => {
2731+ println ! (
2732+ "WARNING: `download-rustc` is enabled, but there are changes to \
2733+ compiler/ or library/"
2734+ ) ;
2735+ Some ( commit. to_string ( ) )
27452736 }
2746- println ! (
2747- "WARNING: `download-rustc` is enabled, but there are changes to \
2748- compiler/ or library/"
2749- ) ;
2737+ Some ( false ) => Some ( commit. to_string ( ) ) ,
2738+ None => None ,
27502739 }
2751-
2752- Some ( commit. to_string ( ) )
27532740 }
27542741
27552742 fn parse_download_ci_llvm (
@@ -2847,6 +2834,42 @@ impl Config {
28472834
28482835 Some ( commit. to_string ( ) )
28492836 }
2837+
2838+ /// Check for changes in specified directories since a given commit.
2839+ /// Returns Some(true) if changes exist, Some(false) if no changes, None if check should be ignored.
2840+ pub fn check_for_changes (
2841+ & self ,
2842+ dirs : & [ PathBuf ] ,
2843+ commit : & str ,
2844+ option_name : & str ,
2845+ if_unchanged : bool ,
2846+ ) -> Option < bool > {
2847+ let mut git = helpers:: git ( Some ( & self . src ) ) ;
2848+ git. args ( [ "diff-index" , "--quiet" , commit, "--" ] ) ;
2849+
2850+ for dir in dirs {
2851+ git. arg ( self . src . join ( dir) ) ;
2852+ }
2853+
2854+ let has_changes = !t ! ( git. as_command_mut( ) . status( ) ) . success ( ) ;
2855+
2856+ if has_changes {
2857+ if if_unchanged {
2858+ if self . verbose > 0 {
2859+ println ! (
2860+ "WARNING: saw changes to one of {:?} since {}; \
2861+ ignoring `{}`",
2862+ dirs, commit, option_name
2863+ ) ;
2864+ }
2865+ None
2866+ } else {
2867+ Some ( true )
2868+ }
2869+ } else {
2870+ Some ( false )
2871+ }
2872+ }
28502873}
28512874
28522875/// Compares the current `Llvm` options against those in the CI LLVM builder and detects any incompatible options.
0 commit comments