Skip to content

feat(cli): register new branches in the canonical gh-stack file - #68

Open
lettertwo wants to merge 4 commits into
gh-stack-linking-doctorfrom
gh-stack-write-path
Open

feat(cli): register new branches in the canonical gh-stack file#68
lettertwo wants to merge 4 commits into
gh-stack-linking-doctorfrom
gh-stack-write-path

Conversation

@lettertwo

@lettertwo lettertwo commented Aug 28, 2026

Copy link
Copy Markdown
Owner

This PR makes workon new register the branch it creates in the canonical gh-stack file.

Upstream's cmd/add.go unconditionally runs git.CheckoutBranch(branchName), and git's
one-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. workon writes the file
directly instead.

gh_stack::register_branch appends branch to the stack that currently ends at base_branch, with
base set to repo.merge_base(base tip, branch tip) so it stays correct if the base moved. The
document round-trips through serde_json::Value rather than a typed struct, so id, 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_doc could receive a
truncated prefix.

workon.stackAutoTrack is the new config key covering both providers. workon.gtAutoTrack stays as
a deprecated alias, read only when stackAutoTrack is unset. Registration failures stay non-fatal
warnings, matching the Graphite path.

Testing: 647 tests, clippy clean.


Stack created with GitHub Stacks CLIGive Feedback 💬

@lettertwo lettertwo changed the title gh stack write path feat(cli): register new branches in the canonical gh-stack file Aug 28, 2026
@lettertwo
lettertwo force-pushed the gh-stack-write-path branch from 093c8bc to 9e3c317 Compare August 28, 2026 03:13
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