@@ -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 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
+
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,11 @@ 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 , 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
+
1178
1213
if self .use_vendored_sources :
1179
1214
vendor_dir = os .path .join (self .rust_root , "vendor" )
1180
1215
if not os .path .exists (vendor_dir ):
0 commit comments