Skip to content

fix(git): automation restores checkout to base (never leaves repo off-main)#58

Merged
MCamner merged 1 commit into
mainfrom
fix/automation-restore-checkout
Jul 18, 2026
Merged

fix(git): automation restores checkout to base (never leaves repo off-main)#58
MCamner merged 1 commit into
mainfrom
fix/automation-restore-checkout

Conversation

@MCamner

@MCamner MCamner commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Why

The git "auto commit + push" automation commits on the base branch, then branches an mq/update-project-files-* PR branch off it and pushes that — but never restored the checkout. It left the working checkout on the PR branch (off-main) and the base branch holding an unpushed commit. This is exactly the drift that put five stack repos off-main and blocked stack release --all --preflight.

What

  • New tools/scripts/git-restore-to-base.sh — single, testable entrypoint: restores the checkout to the base branch and rewinds the local base ref to origin/<base>. Non-destructive: the commit is already on the pushed PR branch, so nothing is lost, no remote changes, no tags, no force-push. Reports repo / branch / dirty / manual fix if it cannot restore.
  • create_pr_branch_for_push in both terminal/launchers/gitlaunch.sh (zsh) and terminal/menus/mq-git-menu.sh (bash) now calls it at the end — including on push/PR failure (req: restore even on partial failure).
  • New behavioral test tests/git-restore-to-base-smoke.sh proves the repo ends on a clean, in-sync base branch (checkout on main, main == origin/main, tree clean, PR-branch commit preserved, idempotent). Wired into test-all.sh.

Scope

Non-destructive. No tags, no tag-disposition, no execute-wiring, no release runs, no remote tag deletion. Existing wip/preserve-* branches untouched.

Verification

zsh -n / bash -n clean; shellcheck clean; macos-scripts release-check.sh --dry-run --jsonREADY (its smoke suite runs the new test).

…f-main

The 'auto commit + push' flow commits on the base branch, branches an mq/... PR
branch off it, and pushes — but left the checkout on the PR branch (off-main)
and the base branch holding an unpushed commit. That is the drift that put five
stack repos off-main and blocked the multi-repo preflight.

- New tools/scripts/git-restore-to-base.sh: restores the checkout to the base
  branch and rewinds the local base ref to origin (non-destructive — the commit
  is already on the pushed PR branch). Reports repo/branch/dirty/next-command if
  it cannot restore.
- create_pr_branch_for_push (gitlaunch.sh + mq-git-menu.sh) calls it at the end,
  including on push/PR failure, so the checkout is always restored.
- tests/git-restore-to-base-smoke.sh proves the repo ends on a clean, in-sync
  base branch (no off-main, no unpushed); wired into test-all.sh.

Release/preflight is never mixed with an automation branch: after every run the
checkout is back on the base branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@MCamner
MCamner merged commit 871f3b9 into main Jul 18, 2026
3 checks passed
@MCamner
MCamner deleted the fix/automation-restore-checkout branch July 18, 2026 18:05
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.

1 participant