@@ -1162,6 +1162,30 @@ def build_triple(self):
11621162        config  =  self .get_toml ("build" )
11631163        return  config  or  default_build_triple (self .verbose )
11641164
1165+     def  is_git_repository (self , repo_path ):
1166+         return  os .path .isdir (os .path .join (repo_path , ".git" ))
1167+ 
1168+     def  get_latest_commit (self ):
1169+         repo_path  =  self .rust_root 
1170+         author_email  =  self .stage0_data .get ("git_merge_commit_email" )
1171+         if  not  self .is_git_repository (repo_path ):
1172+             return  "<commit>" 
1173+         cmd  =  [
1174+             "git" ,
1175+             "-C" ,
1176+             repo_path ,
1177+             "rev-list" ,
1178+             "--author" ,
1179+             author_email ,
1180+             "-n1" ,
1181+             "HEAD" ,
1182+         ]
1183+         try :
1184+             commit  =  subprocess .check_output (cmd , universal_newlines = True ).strip ()
1185+             return  commit  or  "<commit>" 
1186+         except  subprocess .CalledProcessError :
1187+             return  "<commit>" 
1188+ 
11651189    def  check_vendored_status (self ):
11661190        """Check that vendoring is configured properly""" 
11671191        # keep this consistent with the equivalent check in bootstrap: 
@@ -1174,7 +1198,8 @@ def check_vendored_status(self):
11741198                eprint ("      use vendored sources by default." )
11751199
11761200        cargo_dir  =  os .path .join (self .rust_root , ".cargo" )
1177-         url  =  "https://ci-artifacts.rust-lang.org/rustc-builds/<commit>/rustc-nightly-src.tar.xz" 
1201+         commit  =  self .get_latest_commit ()
1202+         url  =  f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit }  /rustc-nightly-src.tar.xz" 
11781203        if  self .use_vendored_sources :
11791204            vendor_dir  =  os .path .join (self .rust_root , "vendor" )
11801205            if  not  os .path .exists (vendor_dir ):
0 commit comments