@@ -1162,6 +1162,38 @@ 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 = f"{ self .rust_root } /src/stage0"
1187
+ print (file_path )
1188
+ keys = ["git_merge_commit_email" , "nightly_branch" ]
1189
+ values = []
1190
+ with open (file_path , "r" ) as file :
1191
+ for line in file :
1192
+ for key in keys :
1193
+ if line .startswith (f"{ key } =" ):
1194
+ values .append (line .split ("=" , 1 )[1 ].strip ())
1195
+ return values
1196
+
1165
1197
def check_vendored_status (self ):
1166
1198
"""Check that vendoring is configured properly"""
1167
1199
# keep this consistent with the equivalent check in bootstrap:
@@ -1174,7 +1206,11 @@ def check_vendored_status(self):
1174
1206
eprint (" use vendored sources by default." )
1175
1207
1176
1208
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"
1209
+ repo_path = self .rust_root
1210
+ git_merge_commit_email , nightly_branch = self .get_values ()
1211
+ commit = self .get_latest_commit (repo_path , nightly_branch , git_merge_commit_email )
1212
+ url = f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit } /rustc-nightly-src.tar.xz"
1213
+
1178
1214
if self .use_vendored_sources :
1179
1215
vendor_dir = os .path .join (self .rust_root , "vendor" )
1180
1216
if not os .path .exists (vendor_dir ):
0 commit comments