Documentation
¶
Overview ¶
Package split implements logic for branch split commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchRequest ¶
type BranchRequest struct {
Branch string // required
Options *Options // optional, defaults to nil
// SelectCommits is a function that allows the user to select commits
// for splitting the branch if the --at flag is not provided.
SelectCommits func(context.Context, []git.CommitDetail) ([]Point, error)
}
BranchRequest is a request to split a branch.
The list of split points in the branch may be specified as options, or via SelectCommits. If a split point requests the original branch name, then there MUST be another split point for the HEAD commit (to take over the original branch name).
type BranchResult ¶ added in v0.18.0
type BranchResult struct {
// Top is the name of the branch assigned to the topmost commit
// after the split.
//
// This is normally the original branch name,
// but if the original branch was reassigned to a lower commit,
// this will be the name of the branch
// assigned to the original HEAD commit.
Top string
}
BranchResult is the result of splitting a branch.
type GitRepository ¶
type GitRepository interface {
BranchExists(ctx context.Context, branch string) bool
PeelToCommit(ctx context.Context, ref string) (git.Hash, error)
SetBranchUpstream(ctx context.Context, branch, upstream string) error
BranchUpstream(ctx context.Context, branch string) (string, error)
ListCommitsDetails(ctx context.Context, commits git.CommitRange) iter.Seq2[git.CommitDetail, error]
SetRef(ctx context.Context, req git.SetRefRequest) error
}
GitRepository provides treeless read/write access to the Git state.
type Handler ¶
type Handler struct {
Log *silog.Logger // required
View ui.View // required
Repository GitRepository // required
Store Store // required
Service Service // required
FindForge func(forgeID string) (forge.Forge, bool) // required
HighlightStyle lipgloss.Style // required
}
Handler handles gs's branch split commands.
func (*Handler) SplitBranch ¶
func (h *Handler) SplitBranch(ctx context.Context, req *BranchRequest) (*BranchResult, error)
SplitBranch splits a branch into two or more branches along commit boundaries.
type Options ¶
type Options struct {
At []Point `placeholder:"COMMIT:NAME" help:"Commits to split the branch at."`
}
Options defines options for the SplitBranch method. These are exposed as flags in the CLI
type Point ¶
type Point struct {
// Commit is the git commit hash to split at.
Commit string
// Name is the name of the new branch to create at the commit.
Name string
}
Point represents a commit:name pair for splitting.