From 4689e316e44a6561c2405b5fa76a60412d7b1e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 16 Sep 2026 20:53:07 +0200 Subject: [PATCH] Load nightly commit SHA from CI instead of from `rustc` --- src/bin/rustc_josh_sync.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/bin/rustc_josh_sync.rs b/src/bin/rustc_josh_sync.rs index a97469b..12ddd0d 100644 --- a/src/bin/rustc_josh_sync.rs +++ b/src/bin/rustc_josh_sync.rs @@ -6,7 +6,7 @@ use rustc_josh_sync::josh::{JoshProxy, try_install_josh_proxy}; use rustc_josh_sync::sync::{ DEFAULT_UPSTREAM_REPO, FilterVersion, GitSync, PullMode, RustcPullError, }; -use rustc_josh_sync::utils::{get_current_head_sha, prompt, run_command}; +use rustc_josh_sync::utils::{get_current_head_sha, prompt}; use std::path::{Path, PathBuf}; use toml_edit::Document; @@ -232,19 +232,20 @@ fn last_pulled_upstream_sha( rust_version_path.display() ) })?; - run_command( - &["rustc", &format!("+{nightly}"), "--version", "--verbose"], - false, - )? - .lines() - .find(|line| line.starts_with("commit-hash: ")) - .and_then(|line| line.split_whitespace().last()) - .ok_or_else(|| { - anyhow::anyhow!( - "cannot find commit-hash in `rustc +{nightly} --version --verbose` output" - ) - })? - .to_string() + println!("Found previous nightly version {nightly}"); + + let nightly_date = nightly.strip_prefix("nightly-").unwrap_or(nightly); + let mut response = ureq::get(format!( + "https://static.rust-lang.org/dist/{nightly_date}/channel-rust-nightly-git-commit-hash.txt" + )).call()?; + let text = response.body_mut().read_to_string()?; + if !response.status().is_success() { + return Err(anyhow::anyhow!( + "Cannot get commit hash of {nightly} from CI: {}\n{text}", + response.status(), + )); + } + text.trim().to_string() } })) }