feat: add worktree management with per-worktree trunks#1250
Open
ed-irl wants to merge 4 commits into
Open
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
cb2d78c to
a4ba721
Compare
a4ba721 to
f05db8b
Compare
9344b53 to
9dc799e
Compare
Adds an auto-resolve path for restack-flavored rebase conflicts.
When configured and enabled, git-spice invokes a user-supplied
script on every rebase conflict and, if the script reports the
conflict resolved, stages the files and continues the rebase
without intervention.
Shared with the rest of git-spice's script-driven features via the
protocol surface on ed-irl/scriptrun:
- Uses scriptrun.ResolveResponse for the JSON output schema and
scriptrun.QAPair for resolution-file entries -- no duplicated
types.
- Passes the shared GS_OPERATION / GS_BRANCH / GS_BASE env via
scriptrun.EnvFor. Operation is derived from Request.ContinueCommand
so each restack flavour reports its own value (branch-restack,
upstack-restack, downstack-restack, stack-restack, repo-restack).
- Iteration cap reads spice.scriptResolve.maxIterations
(default 10) via Handler.MaxResolveIterations, replacing the
previously private constant. main.go wires it through.
- Resolution file lives at .spice/resolutions/restack.json under
spicedir; the old .spice_resolution.json root-level path is
gone.
- Per-protocol details (env contract, JSON schema, persistence,
iteration cap, fall-through) are documented once in
doc/src/guide/scripts.md; doc/src/guide/restack-auto-resolve.md
is now a thin page that defers there and only documents
restack-specific UX (Claude Code recipe, the
GS_OPERATION values restack uses, the resolution-file key
layout).
CLI:
- All restack flavours (gs branch/upstack/downstack/stack/repo
restack) accept --auto-resolve / --no-auto-resolve, with the
default coming from spice.restack.autoResolve.
- The resolver is configured via spice.restack.resolver (script
body).
Tests:
- Existing success / disabled scripts updated to assert the new
.spice/resolutions/restack.json path.
- Six new script tests cover the protocol surfaces and bring
restack to parity with the integration-auto-resolve coverage:
assumptions, invalid_output, unresolved_no_questions,
iteration_cap (configurable via spice.scriptResolve.maxIterations),
persists_across_restacks, and env (GS_OPERATION / GS_BRANCH /
GS_BASE contract).
When --auto-resolve was requested but spice.restack.resolver was not set, the conflict silently fell through to manual resolution with no indication the flag was ignored. Emit a warning pointing at the config key instead.
9dc799e to
3be01d0
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.
Adds
gs worktree createandgs worktree list, plus the per-worktree trunk machinery they rely on, and worktree-aware filtering forlogandrepo restack.Per-worktree trunks:
remote ref as the canonical trunk, so sync and restack in different
worktrees never contend on a single shared trunk checkout.
worktree-trunkskey (missing key = no worktree trunks, so oldrepos and binaries are unaffected). New Store methods: IsTrunk,
TrunkFor, WorktreeTrunks, Register/UnregisterWorktreeTrunk.
IsTrunk / isTrunk, so every registered worktree trunk is a graph
root: traversals (Bottom, Downstack) stop at it and it can be a
base but not itself tracked.
Commands:
gs worktree create <path>creates a Git worktree and, by default,a per-worktree trunk named after the directory (or --trunk),
tracking the canonical trunk's remote ref. -b stacks a tracked
branch on it; --no-trunk keeps the legacy detached-HEAD behavior.
gs worktree listshows each worktree, its checked-out branch, andits stack.
Worktree-aware filtering:
branch checked out in a given worktree.
log short -w/--worktreefilters the listing to the currentworktree's stacks;
repo restack -w/--worktreerestacks only thosestacks. List and sync render and pull against the worktree's own
trunk via TrunkFor.
Tests:
graph-root semantics, canonical-trunk rejection) and for
worktree-trunk traversal in the branch graph.
and branch create/restack when trunk is checked out elsewhere.