@@ -1162,6 +1162,37 @@ 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 subprocess .run (
1167+ ["git" , "-C" , repo_path , "rev-parse" , "--is-inside-work-tree" ],
1168+ stdout = subprocess .DEVNULL ,
1169+ stderr = subprocess .DEVNULL ,
1170+ ).returncode == 0
1171+
1172+ def get_latest_commit (self , repo_path , branch , author_email ):
1173+ try :
1174+ if not self .is_git_repository (repo_path ):
1175+ return "<commit>"
1176+ cmd = [
1177+ "git" , "-C" , repo_path , "log" , "--format=%H" ,
1178+ "--author" , author_email , branch , "-n" , "1"
1179+ ]
1180+ commit = subprocess .check_output (cmd , text = True ).strip ()
1181+ return commit if commit else "<commit>"
1182+ except subprocess .CalledProcessError :
1183+ return "<commit>"
1184+
1185+ def get_values (self ):
1186+ file_path = "src/stage0"
1187+ keys = ["git_merge_commit_email" , "nightly_branch" ]
1188+ values = []
1189+ with open (file_path , "r" ) as file :
1190+ for line in file :
1191+ for key in keys :
1192+ if line .startswith (f"{ key } =" ):
1193+ values .append (line .split ("=" , 1 )[1 ].strip ())
1194+ return values
1195+
11651196 def check_vendored_status (self ):
11661197 """Check that vendoring is configured properly"""
11671198 # keep this consistent with the equivalent check in bootstrap:
@@ -1174,7 +1205,11 @@ def check_vendored_status(self):
11741205 eprint (" use vendored sources by default." )
11751206
11761207 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"
1208+ repo_path = self .rust_root
1209+ git_merge_commit_email , nightly_branch = self .get_values ()
1210+ commit = self .get_latest_commit (repo_path , nightly_branch , git_merge_commit_email )
1211+ url = f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit } /rustc-nightly-src.tar.xz"
1212+
11781213 if self .use_vendored_sources :
11791214 vendor_dir = os .path .join (self .rust_root , "vendor" )
11801215 if not os .path .exists (vendor_dir ):
0 commit comments