Versions in this module Expand all Collapse all v1 v1.1.0 Dec 26, 2025 v1.0.0 Dec 26, 2025 Changes in this version + var ErrBranchExists = errors.New("branch already exists") + var ErrBranchNotFound = errors.New("branch not found") + var ErrGitDirty = errors.New("working directory has uncommitted changes") + var ErrMergeConflict = errors.New("merge conflict") + var ErrNotGitRepo = errors.New("not a git repository") + var ErrNothingToCommit = errors.New("nothing to commit") + var ErrPushFailed = errors.New("push failed") + var ErrWorktreeExists = errors.New("worktree already exists for this branch") + var ErrWorktreeNotFound = errors.New("worktree not found") + func CleanBranch(s string) string + func ContextWithGit(ctx context.Context, gc *Context) context.Context + func ParseBranch(branch string) (branchType, identifier, extra string) + func SanitizeBranchName(branch string) string + func Slugify(s string) string + type BranchNamer struct + IncludeTitle bool + MaxLength int + TypePrefix string + func DefaultBranchNamer() *BranchNamer + func (n *BranchNamer) ForBugfix(ticketID, description string) string + func (n *BranchNamer) ForFeature(name string) string + func (n *BranchNamer) ForTicket(ticketID, title string) string + func (n *BranchNamer) ForWorkflow(workflowID, identifier string) string + type CommandError struct + Args []string + Command string + Err error + Output string + WorkDir string + func (e *CommandError) Error() string + func (e *CommandError) Unwrap() error + type CommandRunner interface + Run func(workDir string, name string, args ...string) (stdout string, err error) + type CommitAndPushResult struct + Commit *CommitResult + Push *PushResult + type CommitConfig struct + IncludeGeneratedBy bool + RequireTicketRef bool + TicketRefPrefix string + func DefaultCommitConfig() CommitConfig + type CommitMessage struct + Body string + Breaking bool + CoAuthors []string + GeneratedBy string + Scope string + Subject string + TicketRefs []string + Type CommitType + func NewCommitMessage(typ CommitType, subject string) *CommitMessage + func (c *CommitMessage) String() string + func (c *CommitMessage) Validate() error + func (c *CommitMessage) WithBody(body string) *CommitMessage + func (c *CommitMessage) WithBreaking() *CommitMessage + func (c *CommitMessage) WithCoAuthor(email string) *CommitMessage + func (c *CommitMessage) WithScope(scope string) *CommitMessage + func (c *CommitMessage) WithTicketRef(ref string) *CommitMessage + func (c *CommitMessage) WithTicketRefs(refs ...string) *CommitMessage + func (c *CommitMessage) WithoutGeneratedBy() *CommitMessage + type CommitResult struct + Branch string + Date time.Time + Message string + SHA string + type CommitType string + const CommitTypeBuild + const CommitTypeCI + const CommitTypeChore + const CommitTypeDocs + const CommitTypeFeat + const CommitTypeFix + const CommitTypePerf + const CommitTypeRefactor + const CommitTypeRevert + const CommitTypeStyle + const CommitTypeTest + type Context struct + func GitFromContext(ctx context.Context) *Context + func MustGitFromContext(ctx context.Context) *Context + func NewContext(repoPath string, opts ...Option) (*Context, error) + func (g *Context) BranchExists(name string) bool + func (g *Context) Checkout(ref string) error + func (g *Context) CheckoutNew(name string) error + func (g *Context) CheckoutNewAt(name, ref string) error + func (g *Context) CleanupWorktree(worktreePath string) error + func (g *Context) Commit(message string) error + func (g *Context) CommitAll(message string) (*CommitResult, error) + func (g *Context) CommitAllAndPush(message string) (*CommitAndPushResult, error) + func (g *Context) CommitAndPushTo(message, remote string) (*CommitAndPushResult, error) + func (g *Context) CreateBranch(name string) error + func (g *Context) CreateWorktree(branch string) (string, error) + func (g *Context) CurrentBranch() (string, error) + func (g *Context) DeleteBranch(name string, force bool) error + func (g *Context) Diff(base, head string) (string, error) + func (g *Context) DiffStaged() (string, error) + func (g *Context) Fetch(remote string) error + func (g *Context) GetRemoteURL(remote string) (string, error) + func (g *Context) GetWorktree(branch string) (*WorktreeInfo, error) + func (g *Context) GetWorktreeByPath(path string) (*WorktreeInfo, error) + func (g *Context) HeadCommit() (string, error) + func (g *Context) InWorktree(worktreePath string) *Context + func (g *Context) IsBranchPushed(branch string) bool + func (g *Context) IsClean() (bool, error) + func (g *Context) ListWorktrees() ([]WorktreeInfo, error) + func (g *Context) PruneWorktrees() error + func (g *Context) Pull(remote, branch string) error + func (g *Context) Push(remote, branch string, setUpstream bool) error + func (g *Context) PushCurrent() (*PushResult, error) + func (g *Context) PushCurrentTo(remote string) (*PushResult, error) + func (g *Context) RepoPath() string + func (g *Context) RunGit(args ...string) (string, error) + func (g *Context) Stage(files ...string) error + func (g *Context) StageAll() error + func (g *Context) Status() (string, error) + func (g *Context) WorkDir() string + func (g *Context) WorktreeDir() string + type Error struct + Cmd string + Err error + Op string + Output string + func (e *Error) Error() string + func (e *Error) Unwrap() error + type ExecRunner struct + func NewExecRunner() *ExecRunner + func (r *ExecRunner) Run(workDir, name string, args ...string) (string, error) + type MockCall struct + Args []string + Command string + WorkDir string + type MockResponse struct + Err error + Stdout string + type MockResponseBuilder struct + func (b *MockResponseBuilder) Return(stdout string, err error) *MockRunner + type MockRunner struct + Calls []MockCall + DefaultResponse MockResponse + Responses map[string]MockResponse + func NewMockRunner() *MockRunner + func (m *MockRunner) CallCount(name string) int + func (m *MockRunner) OnAnyCommand() *MockResponseBuilder + func (m *MockRunner) OnCommand(name string, args ...string) *MockResponseBuilder + func (m *MockRunner) Run(workDir, name string, args ...string) (string, error) + func (m *MockRunner) WasCalled(name string, args ...string) bool + type Option func(*Context) + func WithRunner(runner CommandRunner) Option + func WithWorktreeDir(dir string) Option + type PushResult struct + Branch string + Remote string + SHA string + SetUpstream bool + URL string + type SequentialMockRunner struct + Calls []MockCall + func NewSequentialMockRunner() *SequentialMockRunner + func (m *SequentialMockRunner) AddOutput(stdout string, err error) *SequentialMockRunner + func (m *SequentialMockRunner) AddOutputError(stdout, errOutput string, err error) *SequentialMockRunner + func (m *SequentialMockRunner) Run(workDir, name string, args ...string) (string, error) + type WorktreeInfo struct + Branch string + Commit string + Path string