Skip to content

Commit 34ece45

Browse files
authored
Rollup merge of rust-lang#139060 - Shourya742:2025-03-28-replace-commit-with-actual-value, r=onur-ozkan
replace commit placeholder in vendor status with actual commit closes: rust-lang#120499
2 parents d2341be + 2ecaac3 commit 34ece45

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/bootstrap/bootstrap.py

+35-1
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,37 @@ 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 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+
11651196
def check_vendored_status(self):
11661197
"""Check that vendoring is configured properly"""
11671198
# keep this consistent with the equivalent check in bootstrap:
@@ -1174,7 +1205,10 @@ def check_vendored_status(self):
11741205
eprint(" use vendored sources by default.")
11751206

11761207
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"
11781212
if self.use_vendored_sources:
11791213
vendor_dir = os.path.join(self.rust_root, "vendor")
11801214
if not os.path.exists(vendor_dir):

0 commit comments

Comments
 (0)