@@ -1162,6 +1162,30 @@ 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 ):
1169
+ repo_path = self .rust_root
1170
+ author_email = self .stage0_data .get ("git_merge_commit_email" )
1171
+ if not self .is_git_repository (repo_path ):
1172
+ return "<commit>"
1173
+ cmd = [
1174
+ "git" ,
1175
+ "-C" ,
1176
+ repo_path ,
1177
+ "rev-list" ,
1178
+ "--author" ,
1179
+ author_email ,
1180
+ "-n1" ,
1181
+ "HEAD" ,
1182
+ ]
1183
+ try :
1184
+ commit = subprocess .check_output (cmd , text = True ).strip ()
1185
+ return commit or "<commit>"
1186
+ except subprocess .CalledProcessError :
1187
+ return "<commit>"
1188
+
1165
1189
def check_vendored_status (self ):
1166
1190
"""Check that vendoring is configured properly"""
1167
1191
# keep this consistent with the equivalent check in bootstrap:
@@ -1174,7 +1198,8 @@ def check_vendored_status(self):
1174
1198
eprint (" use vendored sources by default." )
1175
1199
1176
1200
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"
1201
+ commit = self .get_latest_commit ()
1202
+ url = f"https://ci-artifacts.rust-lang.org/rustc-builds/{ commit } /rustc-nightly-src.tar.xz"
1178
1203
if self .use_vendored_sources :
1179
1204
vendor_dir = os .path .join (self .rust_root , "vendor" )
1180
1205
if not os .path .exists (vendor_dir ):
0 commit comments