Skip to content

feat(worktree): Add worktree commands, per-worktree trunks, and worktree filtering#1162

Open
ed-irl wants to merge 2 commits into
ed-irl/restack-options-paramfrom
branch-comment-forge
Open

feat(worktree): Add worktree commands, per-worktree trunks, and worktree filtering#1162
ed-irl wants to merge 2 commits into
ed-irl/restack-options-paramfrom
branch-comment-forge

Conversation

@ed-irl

@ed-irl ed-irl commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Adds first-class support for working across multiple Git worktrees with independent trunks, so repo sync and restacks in different worktrees no longer contend on a single shared trunk checkout.

Commands

  • gs worktree create <path> (alias wtc): creates a worktree with its own local trunk branch that tracks the same remote ref as the canonical trunk. --trunk names it (defaults to the directory name), --no-trunk keeps the legacy detached-HEAD behavior, and -b/--branch creates a tracked branch stacked on the worktree trunk.
  • gs worktree list (alias wtls): lists worktrees with their checked-out branch and stack.

Per-worktree trunks

  • New worktree-trunks registry in internal/spice/state: WorktreeTrunk, Register/Unregister/WorktreeTrunks, IsTrunk, and TrunkFor(path). The key is additive and optional, so existing repositories and older binaries are unaffected.
  • BranchGraph now treats every registered worktree trunk as a graph root: downstack/Bottom traversals stop at any trunk, and StacksInWorktree returns complete stacks anchored in a given worktree.
  • sync distinguishes the canonical remote trunk from the local trunk it pulls into for the current worktree; in the primary worktree the two are identical.

Worktree-scoped filtering

  • -w/--worktree on log short (implies --all) filters the listing to stacks present in the current worktree and roots them under that worktree's trunk.
  • -w/--worktree on repo restack limits restacking to stacks with a branch in the current worktree.

Adds Repository.WorktreeAdd, regenerated mocks, help/CLI-reference docs, a changelog entry, and unit + script tests covering trunk registry behavior, graph rooting, and the new commands and filters.

Part of #1241

@abhinav

abhinav commented Jun 14, 2026

Copy link
Copy Markdown
Owner

working on merging functionality from this stack next

@abhinav abhinav force-pushed the branch-comment-forge branch from 8648c7a to 0719a4f Compare June 14, 2026 04:05
@abhinav abhinav self-assigned this Jun 14, 2026
@abhinav abhinav force-pushed the branch-comment-forge branch 2 times, most recently from c8254f9 to dabcd6f Compare June 14, 2026 04:30
abhinav pushed a commit that referenced this pull request Jun 14, 2026
The comments CLI needs a local representation for inline comments that
have been prepared but not submitted to a forge yet.

Staged comments now persist the target path, line range, body,
diff side, and optional thread identifier in the spice state database.
That gives command code a stable state boundary before it batches the
comments into a forge review.

Extracted from #1162
@ed-irl ed-irl force-pushed the branch-comment-forge branch from dabcd6f to 1d76154 Compare June 15, 2026 09:52
@ed-irl ed-irl changed the title Add inline code review comment support across forges feat(worktree): Add worktree commands, per-worktree trunks, and worktree filtering Jun 19, 2026
@ed-irl ed-irl force-pushed the branch-comment-forge branch from 1d76154 to 5e57d40 Compare June 19, 2026 01:03
ed-irl added 2 commits June 23, 2026 11:38
Introduces restack.Options{AutoResolve} and threads an opts *Options
parameter through the high-level restack entry points (RestackBranch,
RestackStack, RestackDownstack) and the merge/sync RestackHandler
interfaces, with all current callers passing nil.

This is foundational plumbing for the restack auto-resolve feature.
Landing it on a branch below the consuming stacks lets every branch
inherit the 3-arg signature, rather than the signature change living
on a branch parallel to its callers.
Add inline comment infrastructure across all forges (GitHub, GitLab,
Bitbucket, ShamHub) with three optional interfaces:

- WithInlineComments: list, post, and batch-submit inline comments
- WithThreadResolution: resolve/unresolve review threads
- WithCommentEdit: edit existing review comments

Refactor Bitbucket and GitLab implementations to use typed gateway
client methods (CommentCreate, CommentResolve,
MergeRequestDiscussionCreate, etc.) in place of raw HTTP calls, and
add reply support for Bitbucket inline comments via the Parent field
on CommentCreateRequest.

Introduce the diffmap package for mapping working-tree line numbers
to diff coordinates, and staged comment storage in the spice state
for local comment management before batch submission.

Regenerate forge mocks to reflect the updated MergeChange signature
and the new inline-comment interfaces.
@ed-irl ed-irl changed the base branch from main to ed-irl/restack-options-param June 24, 2026 01:31
@ed-irl ed-irl force-pushed the branch-comment-forge branch from 5e57d40 to b382179 Compare June 24, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog PRs that don't need a changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants