split

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

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.

type GitRepository

type GitRepository interface {
	CreateBranch(ctx context.Context, req git.CreateBranchRequest) error
	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]
}

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) 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.

func (*Point) Decode

func (b *Point) Decode(ctx *kong.DecodeContext) error

Decode parses a COMMIT:NAME specification into a BranchSplit.

type Service

type Service interface {
	LookupBranch(ctx context.Context, name string) (*spice.LookupBranchResponse, error)
}

Service is a subset of spice.Service.

type Store

type Store interface {
	Trunk() string
	Remote() (string, error)
	BeginBranchTx() *state.BranchTx
}

Store is the git-spice data store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL