summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-03 22:04:03 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-03 22:04:03 +1100
commit0e16abbd9510675dd6e30b4be4ea79a6236723c7 (patch)
treeb4952aabb9a999cb126bb489fe02c666b9e00f13
parenttoggles: fix specialws (diff)
downloadcaelestia-cli-0e16abbd9510675dd6e30b4be4ea79a6236723c7.tar.gz
caelestia-cli-0e16abbd9510675dd6e30b4be4ea79a6236723c7.tar.bz2
caelestia-cli-0e16abbd9510675dd6e30b4be4ea79a6236723c7.zip
install: add check for uncommitted changes
Add option to either stash changes, reset to HEAD, or exit
-rw-r--r--install/util.fish20
1 files changed, 20 insertions, 0 deletions
diff --git a/install/util.fish b/install/util.fish
index e5dd7f8..9b258e0 100644
--- a/install/util.fish
+++ b/install/util.fish
@@ -69,11 +69,31 @@ function update-repo -a module dir
set -l remote https://github.com/caelestia-dots/$module.git
if test -d $dir
cd $dir || exit
+
+ # Delete and clone if it's a different git repo
if test "$(git config --get remote.origin.url)" != $remote
cd .. || exit
confirm-overwrite $dir
git clone $remote $dir
else
+ # Check for uncommitted changes
+ if test -n "$(git status --porcelain)"
+ read -l -p "input 'You have uncommitted changes in $dir. Stash, reset or exit? [S/r/e] ' -n" confirm
+
+ if test "$confirm" = 'e' -o "$confirm" = 'E'
+ log 'Exiting...'
+ exit
+ end
+
+ if test "$confirm" = 'r' -o "$confirm" = 'R'
+ log 'Resetting to HEAD...'
+ git reset --hard
+ else
+ log 'Stashing changes...'
+ git stash
+ end
+ end
+
git pull
end
else