From 34863a65862571d5a0f500a30539185a33e96bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20P=C4=99dzim=C4=85=C5=BC?= Date: Wed, 6 May 2026 11:18:13 +0200 Subject: [PATCH] fix(get.sh): auto-stash local modifications instead of aborting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On existing installs, get.sh now automatically runs stash → pull → stash-pop when local modifications would block the pull. Only aborts on actual stash-pop conflicts (requires human judgment). Closes #25. Also bumps VERSION to 1.5.2, adds CHANGELOG entry, and documents the get.sh update behaviour in CLAUDE.md and AGENTS.md. --- AGENTS.md | 1 + CHANGELOG.md | 8 ++++++++ CLAUDE.md | 4 +++- VERSION | 2 +- get.sh | 36 ++++++++++++++++++++++++------------ 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index cb113c5..7c0303e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,6 +13,7 @@ updates (`update.sh`), post-install test suite (`test.sh`), and CI matrix coveri | File | Role | |------|------| +| `get.sh` | curl-pipe bootstrap; auto-stashes local modifications on existing clones before pulling | | `install.sh` | Entry point — profile selection, module orchestration | | `update.sh` | Tool updates with `--check` mode and PATH shadow detection | | `test.sh` | Post-install validation (run after every install and update) | diff --git a/CHANGELOG.md b/CHANGELOG.md index 291e245..74f6bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.5.2] - 2026-05-06 + +### Fixed +- `get.sh`: on existing installs with local modifications, the installer now + automatically stashes changes, pulls the latest, and restores the stash instead + of aborting with a manual-steps error. Only aborts if the stash pop itself has + merge conflicts (content disagreement requiring human judgment). Resolves #25. + ## [1.5.1] - 2026-05-06 ### Fixed diff --git a/CLAUDE.md b/CLAUDE.md index 1470531..12f0e15 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,7 +15,9 @@ install.sh entry point — profile selection, module orchestration update.sh managed tool updates with --check mode + PATH shadow check test.sh post-install validation suite (profile-aware) ci-local.sh local Docker matrix runner — mirrors GitHub CI matrix -get.sh curl-pipe bootstrap (clones repo → runs install.sh) +get.sh curl-pipe bootstrap (clones repo → runs install.sh); + on existing clones auto-stashes local modifications, pulls, + then restores the stash — only aborts on stash-pop conflicts Dockerfile bakes docker profile into an image at build time Dockerfile.nosudo parameterized no-sudo test image (two variants: forced/auto) lib/utils.sh shared logging, sudo detection, GitHub helpers, binary utils diff --git a/VERSION b/VERSION index 26ca594..4cda8f1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.1 +1.5.2 diff --git a/get.sh b/get.sh index e83d1ad..87e7ae1 100755 --- a/get.sh +++ b/get.sh @@ -175,20 +175,32 @@ if [ -d "$DEST/.git" ]; then _die "Repo at $DEST is in an unfinished merge/rebase state.\n Resolve it first: git -C '$DEST' status\n Then: bash '$DEST/install.sh' ${PROFILE:-workstation}" fi - # Local modifications would be overwritten by pull + # Local modifications would be overwritten by pull — auto-stash, pull, restore if ! git -C "$DEST" diff --quiet HEAD 2>/dev/null; then - _warn "Local modifications detected — cannot pull cleanly:" + _warn "Local modifications detected — auto-stashing before pull:" git -C "$DEST" diff --name-only HEAD 2>/dev/null | while IFS= read -r f; do _warn " $f"; done - _warn "Resolve manually, then run install.sh directly (get.sh is gone after curl-pipe):" - _warn " git -C '$DEST' stash" - _warn " git -C '$DEST' pull" - _warn " git -C '$DEST' stash pop" - _warn " # WARNING: if stash pop has conflicts, ~/.zshrc may break." - _warn " # If that happens: exec bash (use bash until resolved)" - _warn " # Accept upstream: git -C '$DEST' checkout -- " - _warn " # Then: git -C '$DEST' stash drop" - _warn " bash '$DEST/install.sh' ${PROFILE:-workstation}" - _die "Aborting — resolve local changes first." + + if ! git -C "$DEST" stash 2>&1; then + _die "git stash failed — resolve manually, then:\n bash '$DEST/install.sh' ${PROFILE:-workstation}" + fi + _ok "Local changes stashed" + + if ! git -C "$DEST" pull --ff-only 2>&1; then + git -C "$DEST" stash pop 2>/dev/null || true + _die "Pull failed (stash restored) — resolve manually:\n git -C '$DEST' pull\n bash '$DEST/install.sh' ${PROFILE:-workstation}" + fi + _ok "Pulled latest" + + if ! git -C "$DEST" stash pop 2>&1; then + _warn "Stash pop has conflicts — your local changes conflict with what was pulled." + _warn " See conflicts: git -C '$DEST' status" + _warn " Accept upstream: git -C '$DEST' checkout -- " + _warn " Drop the stash: git -C '$DEST' stash drop" + _warn " Then install: bash '$DEST/install.sh' ${PROFILE:-workstation}" + _warn " If shell is broken: exec bash" + _die "Resolve stash pop conflicts manually." + fi + _ok "Local changes restored after pull" fi # Local commits ahead of upstream (clean tree but diverged)