@@ -3,7 +3,7 @@ use crate::util::logging::ask_confirm;
33use clap:: Subcommand ;
44use colored:: Colorize ;
55use git2:: build:: { CheckoutBuilder , RepoBuilder } ;
6- use git2:: { FetchOptions , RemoteCallbacks , Repository } ;
6+ use git2:: { FetchOptions , RemoteCallbacks , Repository , StatusOptions } ;
77use path_absolutize:: Absolutize ;
88use regex:: Regex ;
99use reqwest:: header:: { AUTHORIZATION , USER_AGENT } ;
@@ -484,11 +484,23 @@ fn update(config: &mut Config, branch: Option<String>) {
484484
485485 done ! ( "Successfully updated SDK." ) ;
486486 } else {
487- fail ! ( "Cannot update SDK, it has local changes" ) ;
488- info ! (
489- "Go into the repository at {} and manually run `git pull`" ,
490- Config :: sdk_path( ) . to_str( ) . unwrap( )
491- ) ;
487+ let mut opts = StatusOptions :: new ( ) ;
488+ opts. renames_head_to_index ( true )
489+ . include_untracked ( true )
490+ . recurse_untracked_dirs ( true ) ;
491+
492+ let statuses = repo. statuses ( Some ( & mut opts) ) ;
493+ if statuses. is_ok_and ( |x| !x. is_empty ( ) ) {
494+ fail ! ( "Cannot update SDK, it has local changes" ) ;
495+ info ! (
496+ "Go into the repository at {} and manually run `git pull`" ,
497+ Config :: sdk_path( ) . to_str( ) . unwrap( )
498+ ) ;
499+ } else {
500+ switch_to_tag ( config, & repo) ;
501+
502+ done ! ( "Successfully updated SDK." ) ;
503+ }
492504 }
493505}
494506
0 commit comments