@@ -1162,6 +1162,49 @@ 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  (
1167+             subprocess .run (
1168+                 ["git" , "-C" , repo_path , "rev-parse" , "--is-inside-work-tree" ],
1169+                 stdout = subprocess .DEVNULL ,
1170+                 stderr = subprocess .DEVNULL ,
1171+             ).returncode 
1172+             ==  0 
1173+         )
1174+ 
1175+     def  get_latest_commit (self , repo_path , branch , author_email ):
1176+         try :
1177+             if  not  self .is_git_repository (repo_path ):
1178+                 return  "<commit>" 
1179+             cmd  =  [
1180+                 "git" ,
1181+                 "-C" ,
1182+                 repo_path ,
1183+                 "log" ,
1184+                 "--format=%H" ,
1185+                 "--author" ,
1186+                 author_email ,
1187+                 branch ,
1188+                 "-n" ,
1189+                 "1" ,
1190+             ]
1191+             commit  =  subprocess .check_output (cmd , text = True ).strip ()
1192+             return  commit  if  commit  else  "<commit>" 
1193+         except  subprocess .CalledProcessError :
1194+             return  "<commit>" 
1195+ 
1196+     def  get_values (self ):
1197+         file_path  =  f"{ self .rust_root }  /src/stage0" 
1198+         print (file_path )
1199+         keys  =  ["git_merge_commit_email" , "nightly_branch" ]
1200+         values  =  []
1201+         with  open (file_path , "r" ) as  file :
1202+             for  line  in  file :
1203+                 for  key  in  keys :
1204+                     if  line .startswith (f"{ key }  =" ):
1205+                         values .append (line .split ("=" , 1 )[1 ].strip ())
1206+         return  values 
1207+ 
11651208    def  check_vendored_status (self ):
11661209        """Check that vendoring is configured properly""" 
11671210        # keep this consistent with the equivalent check in bootstrap: 
@@ -1174,7 +1217,13 @@ def check_vendored_status(self):
11741217                eprint ("      use vendored sources by default." )
11751218
11761219        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" 
1220+         repo_path  =  self .rust_root 
1221+         git_merge_commit_email , nightly_branch  =  self .get_values ()
1222+         commit  =  self .get_latest_commit (
1223+             repo_path , nightly_branch , git_merge_commit_email 
1224+         )
1225+         url  =  f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit }  /rustc-nightly-src.tar.xz" 
1226+ 
11781227        if  self .use_vendored_sources :
11791228            vendor_dir  =  os .path .join (self .rust_root , "vendor" )
11801229            if  not  os .path .exists (vendor_dir ):
0 commit comments