Skip to content

Commit de13992

Browse files
committed
properly check for local changes when updating sdk
1 parent af1d079 commit de13992

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "geode"
3-
version = "3.7.2"
3+
version = "3.7.3"
44
authors = [
55
"HJfod <dreadrollmusic@gmail.com>",
66
"Camila314 <ilaca314@gmail.com>",

src/sdk.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::util::logging::ask_confirm;
33
use clap::Subcommand;
44
use colored::Colorize;
55
use git2::build::{CheckoutBuilder, RepoBuilder};
6-
use git2::{FetchOptions, RemoteCallbacks, Repository};
6+
use git2::{FetchOptions, RemoteCallbacks, Repository, StatusOptions};
77
use path_absolutize::Absolutize;
88
use regex::Regex;
99
use 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

Comments
 (0)