Documentation
¶
Overview ¶
Package restack implements business logic for high-level restack operations.
Index ¶
- Constants
- type GitWorktree
- type Handler
- func (h *Handler) Restack(ctx context.Context, req *Request) (int, error)
- func (h *Handler) RestackBranch(ctx context.Context, branch string) error
- func (h *Handler) RestackStack(ctx context.Context, branch string) error
- func (h *Handler) RestackUpstack(ctx context.Context, branch string, opts *UpstackOptions) error
- type Request
- type Scope
- type Service
- type Store
- type UpstackOptions
Constants ¶
const ( // ScopeBranch selects just the branch specified in the request. ScopeBranch Scope = 1 << iota // ScopeUpstackExclusive selects the upstack of a branch, // excluding the branch itself. ScopeUpstackExclusive // ScopeUpstack selects the upstack of a branch, // including the branch itself. ScopeUpstack = ScopeBranch | ScopeUpstackExclusive // ScopeDownstack selects the downstack of a branch, // including the branch itself. ScopeDownstack = ScopeBranch | scopeDownstackExclusive // ScopeStack selects the full stack of a branch: // the upstack, downstack, and the branch itself. ScopeStack = ScopeUpstack | ScopeDownstack )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitWorktree ¶
type GitWorktree interface { CurrentBranch(ctx context.Context) (string, error) Checkout(ctx context.Context, branch string) error RootDir() string }
GitWorktree is a subet of the git.Worktree interface.
type Handler ¶
type Handler struct { Log *silog.Logger // required Worktree GitWorktree // required Store Store // required Service Service // required }
Handler implements various restack operations.
func (*Handler) RestackBranch ¶
RestackBranch restacks the given branch onto its base.
func (*Handler) RestackStack ¶
RestackStack restacks the stack of the given branch. This includes all upstack and downtrack branches, as well as the branch itself.
func (*Handler) RestackUpstack ¶
RestackUpstack restacks the upstack of the given branch, including the branch itself, unless SkipStart is set.
type Request ¶
type Request struct { // Branch is the starting point for the restack operation. // This branch will be checked out at the end of the operation. // // Scope is relative to this branch. Branch string // required // ContinueCommand specifies the git-spice command // to run from the Branch's context // to resume this operation if it is interrupted // due to a conflict. ContinueCommand []string // required // Scope specifies which branches are affected by the restack operation. // // Defaults to ScopeBranch. Scope Scope }
Request is a request to restack one or more branches.
type Service ¶
type Service interface { BranchGraph(ctx context.Context, opts *spice.BranchGraphOptions) (*spice.BranchGraph, error) Restack(ctx context.Context, name string) (*spice.RestackResponse, error) RebaseRescue(ctx context.Context, req spice.RebaseRescueRequest) error }
Service is a subset of the spice.Service interface.
type Store ¶
type Store interface {
Trunk() string
}
Store is a subset of the state.Store interface.
type UpstackOptions ¶
type UpstackOptions struct { // SkipStart indicates that the starting branch should not be restacked. SkipStart bool `help:"Do not restack the starting branch"` }
UpstackOptions holds options for restacking the upstack of a branch.