fix: hard reset to remote in bootstrap, add cd and timeout

This commit is contained in:
2026-08-01 16:45:16 -04:00
parent 635705288f
commit 8fed19f72c
+5 -3
View File
@@ -146,15 +146,17 @@ update_repo() {
local TARGET_DIR="$HOME/.config/dotstate/storage" local TARGET_DIR="$HOME/.config/dotstate/storage"
if [[ -d "$TARGET_DIR/.git" ]]; then if [[ -d "$TARGET_DIR/.git" ]]; then
cd "$TARGET_DIR" || return 0
local remote_sha local_sha local remote_sha local_sha
remote_sha=$(git ls-remote "$REPO_URL" HEAD | awk '{print $1}') remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD) [[ -z "$remote_sha" ]] && return 0
local_sha=$(git rev-parse HEAD)
if [[ "$remote_sha" == "$local_sha" ]]; then if [[ "$remote_sha" == "$local_sha" ]]; then
info "Repository up to date" info "Repository up to date"
return 0 return 0
fi fi
info "Repository out of date. Pulling updates..." info "Repository out of date. Pulling updates..."
git -C "$TARGET_DIR" pull &>/dev/null git fetch origin && git reset --hard origin/master && git clean -fd &>/dev/null
else else
info "Repository not found. Cloning..." info "Repository not found. Cloning..."
git clone --depth=1 "$REPO_URL" "$TARGET_DIR" &>/dev/null git clone --depth=1 "$REPO_URL" "$TARGET_DIR" &>/dev/null