@@ -1162,6 +1162,43 @@ 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 , repo_path , author_email ):
1169+ try :
1170+ if (
1171+ not repo_path
1172+ or not author_email
1173+ or not self .is_git_repository (repo_path )
1174+ ):
1175+ return "<commit>"
1176+ cmd = [
1177+ "git" ,
1178+ "-C" ,
1179+ repo_path ,
1180+ "rev-list" ,
1181+ "--author" ,
1182+ author_email ,
1183+ "-n1" ,
1184+ "HEAD" ,
1185+ ]
1186+ commit = subprocess .check_output (cmd , text = True ).strip ()
1187+ return commit if commit else "<commit>"
1188+ except subprocess .CalledProcessError :
1189+ return "<commit>"
1190+
1191+ def get_value (self ):
1192+ file_path = f"{ self .rust_root } /src/stage0"
1193+ target_key = "git_merge_commit_email"
1194+ if not os .path .exists (file_path ):
1195+ return None
1196+ with open (file_path , "r" ) as file :
1197+ for line in file :
1198+ if line .startswith (f"{ target_key } =" ):
1199+ return line .split ("=" , 1 )[1 ].strip ()
1200+ return None
1201+
11651202 def check_vendored_status (self ):
11661203 """Check that vendoring is configured properly"""
11671204 # keep this consistent with the equivalent check in bootstrap:
@@ -1174,7 +1211,10 @@ def check_vendored_status(self):
11741211 eprint (" use vendored sources by default." )
11751212
11761213 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"
1214+ repo_path = self .rust_root
1215+ git_merge_commit_email = self .get_value ()
1216+ commit = self .get_latest_commit (repo_path , git_merge_commit_email )
1217+ url = f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit } /rustc-nightly-src.tar.xz"
11781218 if self .use_vendored_sources :
11791219 vendor_dir = os .path .join (self .rust_root , "vendor" )
11801220 if not os .path .exists (vendor_dir ):
0 commit comments