@@ -180,8 +180,8 @@ fn gather_pgo_profile<'a>(
180180
181181 let ( train_path, label) = match & train_crate {
182182 PgoTrainingCrate :: RustAnalyzer => ( PathBuf :: from ( "." ) , "itself" ) ,
183- PgoTrainingCrate :: GitHub ( url ) => {
184- ( download_crate_for_training ( sh, & pgo_dir, url ) ?, url . as_str ( ) )
183+ PgoTrainingCrate :: GitHub ( repo ) => {
184+ ( download_crate_for_training ( sh, & pgo_dir, repo ) ?, repo . as_str ( ) )
185185 }
186186 } ;
187187
@@ -212,12 +212,20 @@ fn gather_pgo_profile<'a>(
212212}
213213
214214/// Downloads a crate from GitHub, stores it into `pgo_dir` and returns a path to it.
215- fn download_crate_for_training ( sh : & Shell , pgo_dir : & Path , url : & str ) -> anyhow:: Result < PathBuf > {
216- let normalized_path = url. replace ( "/" , "-" ) ;
215+ fn download_crate_for_training ( sh : & Shell , pgo_dir : & Path , repo : & str ) -> anyhow:: Result < PathBuf > {
216+ let mut it = repo. splitn ( 2 , '@' ) ;
217+ let repo = it. next ( ) . unwrap ( ) ;
218+ let revision = it. next ( ) ;
219+
220+ // FIXME: switch to `--revision` here around 2035 or so
221+ let revision =
222+ if let Some ( revision) = revision { & [ "--branch" , revision] as & [ & str ] } else { & [ ] } ;
223+
224+ let normalized_path = repo. replace ( "/" , "-" ) ;
217225 let target_path = pgo_dir. join ( normalized_path) ;
218- cmd ! ( sh, "git clone --depth 1 https://github.com/{url } {target_path}" )
226+ cmd ! ( sh, "git clone --depth 1 https://github.com/{repo} {revision... } {target_path}" )
219227 . run ( )
220- . with_context ( || "cannot download PGO training crate from {url }" ) ?;
228+ . with_context ( || "cannot download PGO training crate from {repo }" ) ?;
221229
222230 Ok ( target_path)
223231}
0 commit comments