diff --git a/bootstrap.sh b/bootstrap.sh index dbe3fb6..fb0a94f 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -142,7 +142,14 @@ update_repo() { local TARGET_DIR="$HOME/.config/dotstate/storage" if [[ -d "$TARGET_DIR/.git" ]]; then - info "Repository exists. Pulling updates..." + local remote_sha local_sha + remote_sha=$(git ls-remote origin HEAD | awk '{print $1}') + local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD) + if [[ "$remote_sha" == "$local_sha" ]]; then + info "Repository up to date" + return 0 + fi + info "Repository out of date. Pulling updates..." git -C "$TARGET_DIR" pull &>/dev/null else info "Repository not found. Cloning..." diff --git a/default/.config/zsh/functions.zsh b/default/.config/zsh/functions.zsh index aaed0c8..ac27868 100644 --- a/default/.config/zsh/functions.zsh +++ b/default/.config/zsh/functions.zsh @@ -16,12 +16,17 @@ update_repo() { local TARGET_DIR="$HOME/.config/dotstate/storage" if [[ -d "$TARGET_DIR/.git" ]]; then - info "Repository exists. Pulling updates..." + local remote_sha local_sha + remote_sha=$(git ls-remote origin HEAD | awk '{print $1}') + local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD) + if [[ "$remote_sha" == "$local_sha" ]]; then + info "Repository up to date" + return 0 + fi + info "Repository out of date. Pulling updates..." git -C "$TARGET_DIR" pull &>/dev/null else info "Repository not found. Cloning..." git clone --depth=1 "$REPO_URL" "$TARGET_DIR" &>/dev/null fi - - exec zsh } \ No newline at end of file