From e83674ac51d4dcab73e20cb742dd018271fa9903 Mon Sep 17 00:00:00 2001 From: Jarvis Date: Thu, 2 Apr 2026 20:38:29 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20mosaic=20sync=20=E2=80=94=20auto-stash?= =?UTF-8?q?=20dirty=20worktree=20before=20pull=20--rebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git pull --rebase fails with 'cannot pull with rebase: You have unstaged changes' when the skills repo has local modifications. Fix: detect dirty index/worktree, stash before pull, restore after. Also gracefully handle pull failures (warn and continue with existing checkout) and stash pop conflicts. --- .../tools/_scripts/mosaic-sync-skills | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/mosaic/framework/tools/_scripts/mosaic-sync-skills b/packages/mosaic/framework/tools/_scripts/mosaic-sync-skills index 4958374..45ea77d 100755 --- a/packages/mosaic/framework/tools/_scripts/mosaic-sync-skills +++ b/packages/mosaic/framework/tools/_scripts/mosaic-sync-skills @@ -55,7 +55,26 @@ mkdir -p "$MOSAIC_HOME" "$MOSAIC_SKILLS_DIR" "$MOSAIC_LOCAL_SKILLS_DIR" if [[ $fetch -eq 1 ]]; then if [[ -d "$SKILLS_REPO_DIR/.git" ]]; then echo "[mosaic-skills] Updating skills source: $SKILLS_REPO_DIR" - git -C "$SKILLS_REPO_DIR" pull --rebase + + # Stash any local changes (dirty index or worktree) before pulling + local_changes=0 + if ! git -C "$SKILLS_REPO_DIR" diff --quiet 2>/dev/null || \ + ! git -C "$SKILLS_REPO_DIR" diff --cached --quiet 2>/dev/null; then + local_changes=1 + echo "[mosaic-skills] Stashing local changes..." + git -C "$SKILLS_REPO_DIR" stash push -q -m "mosaic-sync-skills auto-stash" + fi + + if ! git -C "$SKILLS_REPO_DIR" pull --rebase; then + echo "[mosaic-skills] WARN: pull failed — continuing with existing checkout" >&2 + fi + + # Restore stashed changes + if [[ $local_changes -eq 1 ]]; then + echo "[mosaic-skills] Restoring local changes..." + git -C "$SKILLS_REPO_DIR" stash pop -q 2>/dev/null || \ + echo "[mosaic-skills] WARN: stash pop had conflicts — check $SKILLS_REPO_DIR" >&2 + fi else echo "[mosaic-skills] Cloning skills source to: $SKILLS_REPO_DIR" mkdir -p "$(dirname "$SKILLS_REPO_DIR")"