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/<main> 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) <noreply@anthropic.com>
This commit is contained in:
parent
d6d743340d
commit
1c6745f0d0
2 changed files with 14 additions and 12 deletions
|
|
@ -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/<main>` 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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/<main>` 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 <repo> rebase --continue` after `git add`-ing resolved files) or abort (`git -C <repo> 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 != <feature-branch>`:
|
||||
- If branch is empty (detached), prose-ask: "wxwidgets is at detached HEAD `<sha>`. Want me to `git -C wxwidgets checkout <feature-branch>` 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 <repo> (`<feature>`) onto `origin/<main>` — proceed?"
|
||||
- `git -C <path> fetch origin`
|
||||
- `git -C <path> rebase origin/<main>` (this hits the `ask` permission — user confirms again at tool layer)
|
||||
- `git -C <path> rebase origin/<main>` (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 <root> status --short` for staged or unstaged changes to the `kicad` / `wxwidgets` submodule entries. If present, suggest:
|
||||
6. **After all 3 succeed:** check `git -C <root> 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.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue