feat(cli): register new branches in the canonical gh-stack file - #68
Open
lettertwo wants to merge 4 commits into
Open
feat(cli): register new branches in the canonical gh-stack file#68lettertwo wants to merge 4 commits into
lettertwo wants to merge 4 commits into
Conversation
lettertwo
force-pushed
the
gh-stack-write-path
branch
from
August 28, 2026 03:13
093c8bc to
9e3c317
Compare
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.
This PR makes
workon newregister the branch it creates in the canonical gh-stack file.Upstream's
cmd/add.gounconditionally runsgit.CheckoutBranch(branchName), and git'sone-worktree-per-branch rule blocks both checkouts it would need: the new branch is already live in
the new worktree, and the base branch is live wherever it was created.
workonwrites the filedirectly instead.
gh_stack::register_branchappendsbranchto the stack that currently ends atbase_branch, withbaseset torepo.merge_base(base tip, branch tip)so it stays correct if the base moved. Thedocument round-trips through
serde_json::Valuerather than a typed struct, soid,pullRequest,and any field a future gh-stack adds survive on untouched entries. The write is temp-and-rename
against canonical itself, never a worktree's symlinked path, since renaming onto a symlink replaces
the link with a real file.
The read happens under the lock rather than before it. Once the lock is held no lock-respecting
writer can be mid-write, so a pre-lock read is the only way
plan_registered_doccould receive atruncated prefix.
workon.stackAutoTrackis the new config key covering both providers.workon.gtAutoTrackstays asa deprecated alias, read only when
stackAutoTrackis unset. Registration failures stay non-fatalwarnings, matching the Graphite path.
Testing: 647 tests, clippy clean.
Stack created with GitHub Stacks CLI • Give Feedback 💬