@@ -180,8 +180,8 @@ fn gather_pgo_profile<'a>(
180
180
181
181
let ( train_path, label) = match & train_crate {
182
182
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 ( ) )
185
185
}
186
186
} ;
187
187
@@ -212,12 +212,20 @@ fn gather_pgo_profile<'a>(
212
212
}
213
213
214
214
/// 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 ( "/" , "-" ) ;
217
225
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}" )
219
227
. run ( )
220
- . with_context ( || "cannot download PGO training crate from {url }" ) ?;
228
+ . with_context ( || "cannot download PGO training crate from {repo }" ) ?;
221
229
222
230
Ok ( target_path)
223
231
}
0 commit comments