Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/dist.rs')
| -rw-r--r-- | xtask/src/dist.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index 7e26167725..b3d6f06b07 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -180,8 +180,8 @@ fn gather_pgo_profile<'a>( let (train_path, label) = match &train_crate { PgoTrainingCrate::RustAnalyzer => (PathBuf::from("."), "itself"), - PgoTrainingCrate::GitHub(url) => { - (download_crate_for_training(sh, &pgo_dir, url)?, url.as_str()) + PgoTrainingCrate::GitHub(repo) => { + (download_crate_for_training(sh, &pgo_dir, repo)?, repo.as_str()) } }; @@ -212,12 +212,20 @@ fn gather_pgo_profile<'a>( } /// Downloads a crate from GitHub, stores it into `pgo_dir` and returns a path to it. -fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, url: &str) -> anyhow::Result<PathBuf> { - let normalized_path = url.replace("/", "-"); +fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, repo: &str) -> anyhow::Result<PathBuf> { + let mut it = repo.splitn(2, '@'); + let repo = it.next().unwrap(); + let revision = it.next(); + + // FIXME: switch to `--revision` here around 2035 or so + let revision = + if let Some(revision) = revision { &["--branch", revision] as &[&str] } else { &[] }; + + let normalized_path = repo.replace("/", "-"); let target_path = pgo_dir.join(normalized_path); - cmd!(sh, "git clone --depth 1 https://github.com/{url} {target_path}") + cmd!(sh, "git clone --depth 1 https://github.com/{repo} {revision...} {target_path}") .run() - .with_context(|| "cannot download PGO training crate from {url}")?; + .with_context(|| "cannot download PGO training crate from {repo}")?; Ok(target_path) } |