From 1c6745f0d073243e5bdb8975a5f24fcd0169c3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20T=C3=B6rcsv=C3=A1ri?= Date: Fri, 29 May 2026 16:13:08 +0200 Subject: [PATCH] fix(git-workflow): fetch all origins before status snapshot in sync + finish repo-status.sh derives up_to_date_with_main from the local origin/
ref without fetching, so a stale snapshot could mark a repo "up to date" when its origin had actually moved. sync would then report "all up to date" and skip a needed rebase; finish would pass pre-flight and only discover the staleness mid-merge. Both skills now run `for-each-repo.sh fetch origin` as a mandatory first step before the snapshot. Dropped the redundant per-repo fetch from sync's execute step; kept finish's `pull --ff-only` as defense-in-depth. Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/skills/git-feature-finish/SKILL.md | 11 ++++++----- .claude/skills/git-feature-sync/SKILL.md | 15 ++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.claude/skills/git-feature-finish/SKILL.md b/.claude/skills/git-feature-finish/SKILL.md index 41baf26..233b234 100644 --- a/.claude/skills/git-feature-finish/SKILL.md +++ b/.claude/skills/git-feature-finish/SKILL.md @@ -11,11 +11,12 @@ Per-repo main mapping is in `scripts/git-workflow/repos.sh` (root=`main`, subs=` ## Pre-flight (all of these must pass before any merge happens) -1. Run `bash /Users/torcsi/dev/kicad-wasm/scripts/git-workflow/repo-status.sh`. Parse the JSON. -2. All 3 repos must have `dirty: false`. If any is dirty, STOP and tell the user to commit (`/git-feature-commit`) or stash first. -3. All 3 repos must be on the same feature branch (use root's branch as the reference). If not, STOP and report the mismatch. -4. All 3 repos must have `up_to_date_with_main: true` (i.e. the feature is rebased onto the latest main). If any isn't, STOP and instruct: "run `/git-feature-sync` first". -5. None may have `rebase_in_progress: true`. If so, STOP. +1. **Fetch every origin FIRST.** Run `bash /Users/torcsi/dev/kicad-wasm/scripts/git-workflow/for-each-repo.sh fetch origin`. This is mandatory and must happen *before* the status snapshot. `repo-status.sh` derives `up_to_date_with_main` from the local `origin/
` ref **without fetching** — so without this step a repo whose origin has moved looks "up to date", check 5 passes, and the staleness is only discovered mid-merge (the `pull --ff-only` in the steps below would catch it, but then you've already merged the earlier repos). Fetching here makes the pre-flight STOP cleanly with "run `/git-feature-sync` first" instead of bailing partway through. +2. Run `bash /Users/torcsi/dev/kicad-wasm/scripts/git-workflow/repo-status.sh`. Parse the JSON. Because step 1 just fetched, `up_to_date_with_main` now reflects true remote state. +3. All 3 repos must have `dirty: false`. If any is dirty, STOP and tell the user to commit (`/git-feature-commit`) or stash first. +4. All 3 repos must be on the same feature branch (use root's branch as the reference). If not, STOP and report the mismatch. +5. All 3 repos must have `up_to_date_with_main: true` (i.e. the feature is rebased onto the latest main). If any isn't, STOP and instruct: "run `/git-feature-sync` first". +6. None may have `rebase_in_progress: true`. If so, STOP. ## Steps — order: kicad, wxwidgets, root diff --git a/.claude/skills/git-feature-sync/SKILL.md b/.claude/skills/git-feature-sync/SKILL.md index e7502e9..a4fbf4b 100644 --- a/.claude/skills/git-feature-sync/SKILL.md +++ b/.claude/skills/git-feature-sync/SKILL.md @@ -19,25 +19,26 @@ So after the user resolves a conflict manually + runs `git rebase --continue` in ## Steps -1. **Get status snapshot.** Run `bash /Users/torcsi/dev/kicad-wasm/scripts/git-workflow/repo-status.sh` and parse the per-repo JSON. +1. **Fetch every origin FIRST.** Run `bash /Users/torcsi/dev/kicad-wasm/scripts/git-workflow/for-each-repo.sh fetch origin`. This is mandatory on every sync and must happen *before* the status snapshot. `repo-status.sh` derives `up_to_date_with_main` from the local `origin/
` ref **without fetching** — so without this step the work plan (step 4) can wrongly mark a repo "up to date" and skip a needed rebase when its origin has moved. (This is the bug that let a stale sync report "all 3 up to date" while `origin/wasm-port` had actually advanced.) -2. **Pre-flight checks.** +2. **Get status snapshot.** Run `bash /Users/torcsi/dev/kicad-wasm/scripts/git-workflow/repo-status.sh` and parse the per-repo JSON. Because step 1 just fetched, `up_to_date_with_main` now reflects true remote state. + +3. **Pre-flight checks.** - If any repo has `rebase_in_progress: true`, STOP. Tell the user which repo, and that they need to resolve (`git -C rebase --continue` after `git add`-ing resolved files) or abort (`git -C rebase --abort`) before sync can proceed. - Determine the feature branch from root's `branch` field. If root is on its main (`main`) or detached, STOP and say "no feature branch active in root — nothing to sync". - For each submodule with `branch != `: - If branch is empty (detached), prose-ask: "wxwidgets is at detached HEAD ``. Want me to `git -C wxwidgets checkout ` first? (y/N)". On yes, run it (auto-allowed). On no, STOP. - If branch is some other name, STOP and tell the user which repo is on which branch. Don't auto-switch. -3. **Determine work plan.** For each repo, mark "needs rebase" if `up_to_date_with_main: false`. If all three are up-to-date, print "all 3 repos already up to date with their mains" and stop cleanly. +4. **Determine work plan.** For each repo, mark "needs rebase" if `up_to_date_with_main: false`. If all three are up-to-date, print "all 3 repos already up to date with their mains" and stop cleanly. -4. **Execute per repo** in order [root, kicad, wxwidgets]. Skip any repo with `up_to_date_with_main: true`. For each repo that needs rebase: +5. **Execute per repo** in order [root, kicad, wxwidgets]. Skip any repo with `up_to_date_with_main: true`. For each repo that needs rebase: - Prose-announce: "About to rebase (``) onto `origin/
` — proceed?" - - `git -C fetch origin` - - `git -C rebase origin/
` (this hits the `ask` permission — user confirms again at tool layer) + - `git -C rebase origin/
` (origins were already fetched in step 1; this hits the `ask` permission — user confirms again at tool layer) - If the rebase command exits non-zero (conflict), STOP and emit the handoff message (see below). - On success, continue to the next repo. -5. **After all 3 succeed:** check `git -C status --short` for staged or unstaged changes to the `kicad` / `wxwidgets` submodule entries. If present, suggest: +6. **After all 3 succeed:** check `git -C status --short` for staged or unstaged changes to the `kicad` / `wxwidgets` submodule entries. If present, suggest: > Submodule SHAs changed during rebase. When ready: `/git-feature-commit "sync: bump submodule pointers after rebase"`. Do NOT auto-commit.