Skip to content

make git clones idempotent so the script can be re-run - #21

Open
presto8 wants to merge 1 commit into
mainfrom
fix/idempotent-git-clones
Open

presto8 wants to merge 1 commit into
mainfrom
fix/idempotent-git-clones

Conversation

@presto8

@presto8 presto8 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

setup_tmux unconditionally cloned five plugin repos. On a second run
each clone failed with 'already exists and is not an empty directory',
and because the function body was a () subshell under 'set -Eeu' the
non-zero exit aborted the entire script -- contradicting the README's
claim that setup is safe to run multiple times.

Add a clone_or_pull helper that clones when absent and pulls when
present, and use it for the tmux plugins, prezto, zsh-autosuggestions
and fzf-tab. setup_tmux no longer needs to be a subshell now that the
clone destinations are absolute rather than relative to a cd.

Also use 'ln -sf' for the prezto runcom symlinks, which otherwise fail
if the link already exists.

Note: setup_zsh_with_prezto still returns early when $ZPREZTODIR
exists, so a run interrupted partway through that function is not yet
self-healing.


🤖 Generated with Claude Code

setup_tmux unconditionally cloned five plugin repos. On a second run
each clone failed with 'already exists and is not an empty directory',
and because the function body was a () subshell under 'set -Eeu' the
non-zero exit aborted the entire script -- contradicting the README's
claim that setup is safe to run multiple times.

Add a clone_or_pull helper that clones when absent and pulls when
present, and use it for the tmux plugins, prezto, zsh-autosuggestions
and fzf-tab. setup_tmux no longer needs to be a subshell now that the
clone destinations are absolute rather than relative to a cd.

Also use 'ln -sf' for the prezto runcom symlinks, which otherwise fail
if the link already exists.

Note: setup_zsh_with_prezto still returns early when $ZPREZTODIR
exists, so a run interrupted partway through that function is not yet
self-healing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

clone_or_pull still fails or behaves inconsistently in rerun scenarios (existing non-git destinations and submodule checkouts not being updated on pull).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Makes the setup script safer to re-run by avoiding failing git clone operations when repositories already exist, and by making tmux setup independent of cd/subshell behavior.

Changes:

  • Adds a clone_or_pull helper to clone missing repos and update existing ones.
  • Updates zsh/prezto, zsh-autosuggestions, fzf-tab, and tmux plugin installs to use clone_or_pull.
  • Makes prezto runcom symlink creation idempotent (ln -sf) and converts setup_tmux from a subshell to a normal function.
File summaries
File Description
setup Introduces clone_or_pull and refactors multiple plugin install steps to be re-runnable without failing on existing directories/symlinks.
Review details

Suppressed comments (1)

setup:235

  • clone_or_pull supports --recursive for the initial clone, but the update path only runs git pull. For repos with submodules (e.g. prezto), rerunning the script can update the superproject without updating submodule working trees, leaving the checkout inconsistent. Consider updating submodules after a successful pull when a .gitmodules file is present.
        info "updating $(basename "$dest")"
        # don't abort the run if the checkout is dirty or has no upstream
        git -C "$dest" pull --ff-only ||:
    else
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread setup
Comment on lines +231 to +238
if [[ -d "$dest/.git" ]]; then
info "updating $(basename "$dest")"
# don't abort the run if the checkout is dirty or has no upstream
git -C "$dest" pull --ff-only ||:
else
info "cloning $(basename "$dest")"
git clone "$@" "$url" "$dest"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants