@@ -15,7 +15,9 @@ use std::{cmp, env, fs};
1515
1616use build_helper:: ci:: CiEnv ;
1717use build_helper:: exit;
18- use build_helper:: git:: { GitConfig , get_closest_merge_commit, output_result} ;
18+ use build_helper:: git:: {
19+ GitConfig , PathFreshness , check_path_modifications, get_closest_merge_commit, output_result,
20+ } ;
1921use serde:: { Deserialize , Deserializer } ;
2022use serde_derive:: Deserialize ;
2123#[ cfg( feature = "tracing" ) ]
@@ -3122,9 +3124,7 @@ impl Config {
31223124 self . update_submodule ( "src/llvm-project" ) ;
31233125
31243126 // Check for untracked changes in `src/llvm-project` and other important places.
3125- let has_changes = self
3126- . last_modified_commit ( LLVM_INVALIDATION_PATHS , "download-ci-llvm" , true )
3127- . is_none ( ) ;
3127+ let has_changes = self . has_changes_from_upstream ( LLVM_INVALIDATION_PATHS ) ;
31283128
31293129 // Return false if there are untracked changes, otherwise check if CI LLVM is available.
31303130 if has_changes { false } else { llvm:: is_ci_llvm_available_for_target ( self , asserts) }
@@ -3155,6 +3155,17 @@ impl Config {
31553155 }
31563156 }
31573157
3158+ /// Returns true if any of the `paths` have been modified locally.
3159+ fn has_changes_from_upstream ( & self , paths : & [ & str ] ) -> bool {
3160+ let freshness =
3161+ check_path_modifications ( Some ( & self . src ) , & self . git_config ( ) , paths, CiEnv :: current ( ) )
3162+ . unwrap ( ) ;
3163+ match freshness {
3164+ PathFreshness :: LastModifiedUpstream { .. } => false ,
3165+ PathFreshness :: HasLocalModifications { .. } => true ,
3166+ }
3167+ }
3168+
31583169 /// Returns the last commit in which any of `modified_paths` were changed,
31593170 /// or `None` if there are untracked changes in the working directory and `if_unchanged` is true.
31603171 pub fn last_modified_commit (
0 commit comments