@@ -16,7 +16,9 @@ use std::{cmp, env, fs};
1616
1717use build_helper:: ci:: CiEnv ;
1818use build_helper:: exit;
19- use build_helper:: git:: { GitConfig , get_closest_merge_commit, output_result} ;
19+ use build_helper:: git:: {
20+ GitConfig , PathFreshness , check_path_modifications, get_closest_merge_commit, output_result,
21+ } ;
2022use serde:: { Deserialize , Deserializer } ;
2123use serde_derive:: Deserialize ;
2224#[ cfg( feature = "tracing" ) ]
@@ -3264,9 +3266,7 @@ impl Config {
32643266 self . update_submodule ( "src/llvm-project" ) ;
32653267
32663268 // Check for untracked changes in `src/llvm-project` and other important places.
3267- let has_changes = self
3268- . last_modified_commit ( LLVM_INVALIDATION_PATHS , "download-ci-llvm" , true )
3269- . is_none ( ) ;
3269+ let has_changes = self . has_changes_from_upstream ( LLVM_INVALIDATION_PATHS ) ;
32703270
32713271 // Return false if there are untracked changes, otherwise check if CI LLVM is available.
32723272 if has_changes { false } else { llvm:: is_ci_llvm_available_for_target ( self , asserts) }
@@ -3297,6 +3297,17 @@ impl Config {
32973297 }
32983298 }
32993299
3300+ /// Returns true if any of the `paths` have been modified locally.
3301+ fn has_changes_from_upstream ( & self , paths : & [ & str ] ) -> bool {
3302+ let freshness =
3303+ check_path_modifications ( Some ( & self . src ) , & self . git_config ( ) , paths, CiEnv :: current ( ) )
3304+ . unwrap ( ) ;
3305+ match freshness {
3306+ PathFreshness :: LastModifiedUpstream { .. } => false ,
3307+ PathFreshness :: HasLocalModifications { .. } => true ,
3308+ }
3309+ }
3310+
33003311 /// Returns the last commit in which any of `modified_paths` were changed,
33013312 /// or `None` if there are untracked changes in the working directory and `if_unchanged` is true.
33023313 pub fn last_modified_commit (
0 commit comments