From c7e6364c78b5a90ebf5e90d068afb68b408bbb24 Mon Sep 17 00:00:00 2001 From: Jeremy McClure Date: Sat, 1 Aug 2026 16:32:50 -0400 Subject: [PATCH] Update 1 file: functions.zsh --- default/.config/zsh/functions.zsh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/default/.config/zsh/functions.zsh b/default/.config/zsh/functions.zsh index 3778b87..36ecfea 100644 --- a/default/.config/zsh/functions.zsh +++ b/default/.config/zsh/functions.zsh @@ -15,19 +15,17 @@ dotstate_update() { local REPO_URL="https://git.jeremymcclure.com/jeremy/dotstate-storage.git" local TARGET_DIR="$HOME/.config/dotstate/storage" - if [[ -d "$TARGET_DIR/.git" ]]; then - local remote_sha local_sha - remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}') - [[ -z "$remote_sha" ]] && return 0 - local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD) - [[ "$remote_sha" == "$local_sha" ]] && return 0 - 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 + [[ "$(id -u)" -ne "$(stat -c '%u' "$TARGET_DIR" 2>/dev/null)" ]] && return 0 + [[ ! -d "$TARGET_DIR/.git" ]] && return 0 - dotstate activate &>/dev/null + local remote_sha local_sha + remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}') + [[ -z "$remote_sha" ]] && return 0 + local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD) + [[ "$remote_sha" == "$local_sha" ]] && return 0 + + info "Repository out of date. Pulling updates..." + git -C "$TARGET_DIR" pull &>/dev/null + dotstate activate exec zsh } \ No newline at end of file