fix: cd to target dir before git commands to avoid CWD permission issues

This commit is contained in:
2026-08-01 16:41:46 -04:00
parent c7e6364c78
commit 4a35d31483
+4 -2
View File
@@ -18,14 +18,16 @@ dotstate_update() {
[[ "$(id -u)" -ne "$(stat -c '%u' "$TARGET_DIR" 2>/dev/null)" ]] && return 0 [[ "$(id -u)" -ne "$(stat -c '%u' "$TARGET_DIR" 2>/dev/null)" ]] && return 0
[[ ! -d "$TARGET_DIR/.git" ]] && return 0 [[ ! -d "$TARGET_DIR/.git" ]] && return 0
cd "$TARGET_DIR" || return 0
local remote_sha local_sha local remote_sha local_sha
remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}') remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
[[ -z "$remote_sha" ]] && return 0 [[ -z "$remote_sha" ]] && return 0
local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD) local_sha=$(git rev-parse HEAD)
[[ "$remote_sha" == "$local_sha" ]] && return 0 [[ "$remote_sha" == "$local_sha" ]] && return 0
info "Repository out of date. Pulling updates..." info "Repository out of date. Pulling updates..."
git -C "$TARGET_DIR" pull &>/dev/null git pull &>/dev/null
dotstate activate dotstate activate
exec zsh exec zsh
} }