fix(git): automation restores checkout to base (never leaves repo off-main)#58
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 blockedstack release --all --preflight.What
tools/scripts/git-restore-to-base.sh— single, testable entrypoint: restores the checkout to the base branch and rewinds the local base ref toorigin/<base>. Non-destructive: the commit is already on the pushed PR branch, so nothing is lost, no remote changes, no tags, no force-push. Reportsrepo / branch / dirty / manual fixif it cannot restore.create_pr_branch_for_pushin bothterminal/launchers/gitlaunch.sh(zsh) andterminal/menus/mq-git-menu.sh(bash) now calls it at the end — including on push/PR failure (req: restore even on partial failure).tests/git-restore-to-base-smoke.shproves the repo ends on a clean, in-sync base branch (checkout on main, main == origin/main, tree clean, PR-branch commit preserved, idempotent). Wired intotest-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 --json→ READY (its smoke suite runs the new test).