@@ -1162,6 +1162,37 @@ def build_triple(self):
1162
1162
config = self .get_toml ("build" )
1163
1163
return config or default_build_triple (self .verbose )
1164
1164
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 not self .is_git_repository (repo_path ):
1171
+ return "<commit>"
1172
+ cmd = [
1173
+ "git" ,
1174
+ "-C" ,
1175
+ repo_path ,
1176
+ "rev-list" ,
1177
+ "--author" ,
1178
+ author_email ,
1179
+ "-n1" ,
1180
+ "HEAD" ,
1181
+ ]
1182
+ commit = subprocess .check_output (cmd , text = True ).strip ()
1183
+ return commit if commit else "<commit>"
1184
+ except subprocess .CalledProcessError :
1185
+ return "<commit>"
1186
+
1187
+ def get_value (self ):
1188
+ file_path = f"{ self .rust_root } /src/stage0"
1189
+ target_key = "git_merge_commit_email"
1190
+ with open (file_path , "r" ) as file :
1191
+ for line in file :
1192
+ if line .startswith (f"{ target_key } =" ):
1193
+ return line .split ("=" , 1 )[1 ].strip ()
1194
+ return None
1195
+
1165
1196
def check_vendored_status (self ):
1166
1197
"""Check that vendoring is configured properly"""
1167
1198
# keep this consistent with the equivalent check in bootstrap:
@@ -1174,7 +1205,10 @@ def check_vendored_status(self):
1174
1205
eprint (" use vendored sources by default." )
1175
1206
1176
1207
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 = self .get_value ()
1210
+ commit = self .get_latest_commit (repo_path , git_merge_commit_email )
1211
+ url = f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit } /rustc-nightly-src.tar.xz"
1178
1212
if self .use_vendored_sources :
1179
1213
vendor_dir = os .path .join (self .rust_root , "vendor" )
1180
1214
if not os .path .exists (vendor_dir ):
0 commit comments