fix: ensure reset works with local modifications
This commit is contained in:
+1
-1
@@ -182,7 +182,7 @@ update_repo() {
|
||||
local old_sha
|
||||
old_sha=$(git rev-parse HEAD)
|
||||
git fetch origin &>/dev/null && git reset --hard origin/master &>/dev/null && git clean -fd &>/dev/null
|
||||
git log --format='%C(yellow)%h%C(reset) %C(cyan)%ar%C(reset) %s' "$old_sha"..HEAD
|
||||
git log --format='%C(yellow)%h%C(reset) %C(cyan)%ar%C(reset) %s' -10
|
||||
else
|
||||
info "Repository not found. Cloning..."
|
||||
git clone --depth=1 "$REPO_URL" "$TARGET_DIR" &>/dev/null
|
||||
|
||||
@@ -28,17 +28,17 @@ dotstate-update() {
|
||||
remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
|
||||
[[ -z "$remote_sha" ]] && { cd ~; return 0; }
|
||||
local_sha=$(git rev-parse HEAD)
|
||||
if [[ "$remote_sha" == "$local_sha" ]]; then
|
||||
local has_changes=false
|
||||
[[ -n "$(git status --porcelain)" ]] && has_changes=true
|
||||
if [[ "$remote_sha" == "$local_sha" && "$has_changes" == "false" ]]; then
|
||||
cd ~
|
||||
return 0
|
||||
fi
|
||||
|
||||
warn "Dotfiles out of date. Updating..."
|
||||
printf "\033[1;34m────────────────────────────────────────────────────\033[0m\n"
|
||||
local old_sha
|
||||
old_sha=$(git rev-parse HEAD)
|
||||
git fetch origin &>/dev/null && git reset --hard origin/master &>/dev/null && git clean -fd &>/dev/null
|
||||
git log -5 --format='%C(yellow)%h%C(reset) %C(cyan)%ar%C(reset) %s' "$old_sha"..HEAD
|
||||
git log -5 --format='%C(yellow)%h%C(reset) %C(cyan)%ar%C(reset) %s'
|
||||
printf "\033[1;34m────────────────────────────────────────────────────\033[0m\n"
|
||||
cd ~
|
||||
dotstate doctor --fix &>/dev/null
|
||||
|
||||
Reference in New Issue
Block a user