@@ -340,17 +340,20 @@ fn update(config: &mut Config, branch: Option<Branch>) {
340
340
}
341
341
}
342
342
343
+ fn switch_to_ref ( repo : & Repository , name : & str ) {
344
+ let ( obj, refer) = repo. revparse_ext ( name) . unwrap ( ) ;
345
+ repo. checkout_tree ( & obj, None ) . expect ( "Unable to checkout tree" ) ;
346
+ match refer {
347
+ Some ( gref) => repo. set_head ( gref. name ( ) . unwrap ( ) ) ,
348
+ None => repo. set_head_detached ( obj. id ( ) ) ,
349
+ } . expect ( "Failed to update head" ) ;
350
+ }
351
+
343
352
fn switch_to_tag ( config : & mut Config , repo : & Repository ) {
344
353
info ! ( "Updating head" ) ;
345
354
346
355
if config. sdk_nightly {
347
- let fetch_head = repo. find_reference ( "FETCH_HEAD" ) . unwrap ( ) ;
348
- let fetch_commit = repo. reference_to_annotated_commit ( & fetch_head) . unwrap ( ) ;
349
- repo. set_head ( "refs/heads/main" ) . unwrap ( ) ;
350
- let mut refer = repo. find_reference ( "refs/heads/main" ) . unwrap ( ) ;
351
- refer. set_target ( fetch_commit. id ( ) , "Fast-Forward" ) . unwrap ( ) ;
352
- repo. checkout_head ( None )
353
- . expect ( "Unable to switch to latest commit" ) ;
356
+ switch_to_ref ( repo, "refs/heads/main" ) ;
354
357
info ! ( "Switched to latest commit" ) ;
355
358
return ;
356
359
}
@@ -374,11 +377,8 @@ fn switch_to_tag(config: &mut Config, repo: &Repository) {
374
377
return ;
375
378
}
376
379
377
- // Change head and checkout
378
- let refname = format ! ( "refs/tags/v{}" , latest_version. as_ref( ) . unwrap( ) ) ;
379
- repo. set_head ( & refname) . unwrap ( ) ;
380
- repo. checkout_head ( None ) . unwrap ( ) ;
381
-
380
+ let tag_name = latest_version. as_ref ( ) . unwrap ( ) . to_string ( ) ;
381
+ switch_to_ref ( repo, & format ! ( "refs/tags/v{}" , tag_name) ) ;
382
382
done ! ( "Updated head to v{}" , latest_version. unwrap( ) ) ;
383
383
}
384
384
@@ -388,7 +388,7 @@ fn install_binaries(config: &mut Config) {
388
388
let target_dir: PathBuf ;
389
389
if config. sdk_nightly {
390
390
info ! ( "Installing nightly binaries" ) ;
391
- release_tag = "Nightly " . into ( ) ;
391
+ release_tag = "nightly " . into ( ) ;
392
392
target_dir = Config :: sdk_path ( ) . join ( "bin/nightly" ) ;
393
393
} else {
394
394
let ver = get_version ( ) ;
@@ -413,7 +413,10 @@ fn install_binaries(config: &mut Config) {
413
413
. send ( )
414
414
. expect ( "Unable to get download info from GitHub" )
415
415
. json :: < GithubReleaseResponse > ( )
416
- . expect ( "Unable to parse GitHub response" ) ;
416
+ . unwrap_or_else ( |_| fatal ! (
417
+ "It appears that \" {}\" is not a valid Geode release" ,
418
+ release_tag
419
+ ) ) ;
417
420
418
421
let mut target_url: Option < String > = None ;
419
422
for asset in res. assets {
0 commit comments