Versions in this module Expand all Collapse all v0 v0.17.15 May 11, 2026 v0.17.14 May 11, 2026 Changes in this version + const DefaultCommandTimeout + const DefaultRemote + const LocalMetadataRefPrefix + const MaxRerereContinueIterations + const MetadataRefPrefix + const RemoteStackMetaRefPrefix + const StackMetaRefPrefix + const WorktreeRefPrefix + var ErrStaleRemoteInfo = errors.New("stale info") + func BuildPatchFromHunks(hunks []Hunk) string + func CanSplitHunk(hunk Hunk) bool + func CountHunkLines(hunk Hunk) (added, removed int) + func GetCurrentDate() string + func GetGitCommonDir(repoRoot string) string + func GetGitDir(repoRoot string) string + func GetHunkHeader(hunk Hunk) string + func GetHunkPreview(hunk Hunk, maxLines int) (preview string, totalLines int, hasMore bool) + func IsBranchNotFoundError(err error) bool + func IsLocalChangesError(err error) bool + func LocalMetadataRefName(branchName string) string + func MetadataRefName(branchName string) string + func StackMetaRefName(stackID string) string + type BranchReader interface + GetAllBranchNames func() ([]string, error) + GetCurrentBranch func() (string, error) + GetCurrentBranchOrSHA func(ctx context.Context) (string, error) + type BranchType string + const BranchTypeUser + const BranchTypeUtility + const BranchTypeWorktreeAnchor + type BranchWriter interface + CheckoutBranch func(ctx context.Context, branchName string) error + CheckoutBranchForce func(ctx context.Context, branchName string) error + CheckoutDetached func(ctx context.Context, revision string) error + CreateAndCheckoutBranch func(ctx context.Context, branchName string) error + CreateBranch func(ctx context.Context, branchName, startPoint string) error + CreateBranchForce func(ctx context.Context, branchName, revision string) error + DeleteBranch func(ctx context.Context, branchName string) error + RenameBranch func(ctx context.Context, oldName, newName string) error + UpdateBranchRef func(ctx context.Context, branchName, revision string) error + type CherryPickOperations interface + CherryPick func(ctx context.Context, commitSHA, onto string) (string, error) + CherryPickAbort func(ctx context.Context) error + CherryPickSimple func(ctx context.Context, commitSHA string) error + type CommandError struct + Args []string + Command string + Err error + Stderr string + Stdout string + func NewCommandError(command string, args []string, stdout, stderr string, err error) *CommandError + func (e *CommandError) Error() string + func (e *CommandError) Unwrap() error + type CommitOptions struct + Amend bool + Edit bool + Message string + NoEdit bool + NoVerify bool + ResetAuthor bool + Verbose int + type CommitReader interface + BatchGetRevisions func(branchNames []string) (map[string]string, []error) + GetCommitAuthor func(branchName string) (string, error) + GetCommitDate func(branchName string) (time.Time, error) + GetCommitHistorySHAs func(branchName string) ([]string, error) + GetCommitLog func(sha, format string) (string, error) + GetCommitRange func(base, head, format string) ([]string, error) + GetCommitRangeSHAs func(base, head string) ([]string, error) + GetCommitSHA func(branchName string, offset int) (string, error) + GetCommitTemplate func(ctx context.Context) (string, error) + GetCurrentRevision func(ctx context.Context) (string, error) + GetParentCommitSHA func(commitSHA string) (string, error) + GetRecentCommits func(branchName string, count int) ([]RecentCommit, error) + GetRevision func(branchName string) (string, error) + LoadAllBranchRevisions func() error + type CommitWriter interface + Commit func(message string, verbose int, noVerify bool) error + CommitAmendNoEdit func(ctx context.Context) error + CommitWithOptions func(opts CommitOptions) error + type ConfigStore struct + func NewConfigStore(repoRoot string) *ConfigStore + func (c *ConfigStore) Add(key, value string) error + func (c *ConfigStore) Exists(key string) bool + func (c *ConfigStore) Get(key string) (string, error) + func (c *ConfigStore) GetAll(key string) ([]string, error) + func (c *ConfigStore) GetBool(key string) (bool, error) + func (c *ConfigStore) GetBoolWithDefault(key string, defaultValue bool) bool + func (c *ConfigStore) GetInt(key string) (int, error) + func (c *ConfigStore) GetIntWithDefault(key string, defaultValue int) int + func (c *ConfigStore) Set(key, value string) error + func (c *ConfigStore) SetBool(key string, value bool) error + func (c *ConfigStore) SetInt(key string, value int) error + func (c *ConfigStore) Unset(key string) error + type DebugLogger interface + Debug func(msg string, args ...any) + type DiffOperations interface + GetChangedFiles func(ctx context.Context, base, head string) ([]string, error) + GetDiffBetween func(ctx context.Context, base, head string, files ...string) (string, error) + GetDiffNumstat func(base, head string) (string, error) + GetMergeBase func(rev1, rev2 string) (string, error) + GetMergeBaseByRef func(ref1, ref2 string) (string, error) + GetMergedBranches func(ctx context.Context, target string) (map[string]bool, error) + GetStagedDiff func(ctx context.Context, files ...string) (string, error) + GetUnstagedDiff func(ctx context.Context, files ...string) (string, error) + IsAncestor func(ancestor, descendant string) (bool, error) + IsDiffEmpty func(ctx context.Context, branchName, base string) (bool, error) + IsMerged func(ctx context.Context, branchName, target string) (bool, error) + ShowCommits func(ctx context.Context, base, head string, patch, stat bool) (string, error) + ShowDiff func(ctx context.Context, left, right string, stat bool) (string, error) + type Hunk struct + Binary bool + Content string + File string + FileMode string + IndexLine string + IsDeletedFile bool + IsNewFile bool + NewCount int + NewStart int + OldCount int + OldStart int + func GenerateNewFileHunk(filePath string, content []byte) Hunk + func ParseDiffOutput(diffOutput string) ([]Hunk, error) + func SplitHunk(hunk Hunk) ([]Hunk, error) + type HunkTarget struct + CommitIndex int + CommitSHA string + Hunk Hunk + type LocalMeta struct + Frozen bool + NavigationCommentID *int64 + NeedsPRBodyUpdate bool + type LockReason string + const LockReasonConsolidating + const LockReasonDraining + const LockReasonNone + const LockReasonUser + func (r LockReason) IsLocked() bool + type MergeOperations interface + GetUnmergedFiles func(ctx context.Context) ([]string, error) + IsMergeInProgress func(ctx context.Context) bool + Merge func(ctx context.Context, branchName string, opts MergeOptions) error + MergeAbort func(ctx context.Context) error + MergeMultiple func(ctx context.Context, branches []string, opts MergeOptions) error + type MergeOptions struct + FFOnly bool + Message string + NoEdit bool + NoFF bool + type MergedParent struct + BranchName string + PRNumber *int + PRState *string + type Meta struct + func NewMeta() *Meta + func NewMetaFrom(f MetaFields) *Meta + func (m *Meta) GetBranchType() BranchType + func (m *Meta) GetLastModifiedAt() *time.Time + func (m *Meta) GetLastModifiedBy() *ModifiedBy + func (m *Meta) GetLocalOnlyHash() *string + func (m *Meta) GetLockReason() LockReason + func (m *Meta) GetMergedDownstack() []MergedParent + func (m *Meta) GetParentBranchName() *string + func (m *Meta) GetParentBranchRevision() *string + func (m *Meta) GetPrInfo() *PrInfoPersistence + func (m *Meta) GetScope() *string + func (m *Meta) GetStackID() *string + func (m *Meta) UnmarshalJSON(data []byte) error + func (m *Meta) WithBranchType(v BranchType) *Meta + func (m *Meta) WithLastModifiedAt(v *time.Time) *Meta + func (m *Meta) WithLastModifiedBy(v *ModifiedBy) *Meta + func (m *Meta) WithLocalOnlyHash(v *string) *Meta + func (m *Meta) WithLockReason(v LockReason) *Meta + func (m *Meta) WithMergedDownstack(v []MergedParent) *Meta + func (m *Meta) WithParentBranchName(v *string) *Meta + func (m *Meta) WithParentBranchRevision(v *string) *Meta + func (m *Meta) WithPrInfo(v *PrInfoPersistence) *Meta + func (m *Meta) WithScope(v *string) *Meta + func (m *Meta) WithStackID(v *string) *Meta + func (m Meta) MarshalJSON() ([]byte, error) + type MetaFields struct + BranchType BranchType + LastModifiedAt *time.Time + LastModifiedBy *ModifiedBy + LocalOnlyHash *string + LockReason LockReason + MergedDownstack []MergedParent + ParentBranchName *string + ParentBranchRevision *string + PrInfo *PrInfoPersistence + Scope *string + StackID *string + type MetadataOperations interface + BatchReadLocalMetadata func(branchNames []string) map[string]*LocalMeta + BatchReadMetadata func(branchNames []string) (map[string]*Meta, map[string]error) + ClearMetadataCache func() + DeleteMetadata func(branchName string) error + GetLocalMetadataRefSHA func(branchName string) string + GetMetadataRefSHA func(branchName string) string + ListMetadata func() (map[string]string, error) + ReadLocalMetadata func(branchName string) (*LocalMeta, error) + ReadMetadata func(branchName string) (*Meta, error) + RenameMetadata func(oldName, newName string) error + WriteLocalMetadata func(branchName string, meta *LocalMeta) error + WriteLocalMetadataBlob func(meta *LocalMeta) (string, error) + WriteMetadata func(branchName string, meta *Meta) error + WriteMetadataBlob func(meta *Meta) (string, error) + type ModifiedBy struct + GitEmail string + GitHubUsername *string + GitName string + type ObjectOperations interface + CatFile func(sha string) (string, error) + CreateBlob func(content string) (string, error) + ReadBlob func(sha string) (string, error) + type PatchOperations interface + ApplyPatch func(ctx context.Context, patchFile string, threeWay bool) error + CheckCommutation func(hunk Hunk, commitSHA, parentSHA string) (bool, error) + type PathOperations interface + CheckoutPaths func(ctx context.Context, branch string, paths []string) error + RemovePaths func(ctx context.Context, paths []string) error + type PrInfoPersistence struct + Base *string + Body *string + IsDraft *bool + LockReason *LockReason + MergeBranch *string + Number *int + State *string + Title *string + URL *string + type PullResult int + const PullConflict + const PullDone + const PullUnneeded + type PushOptions struct + Force bool + ForceWithLease bool + ForceWithLeaseExpectedSHA string + NoVerify bool + type RebaseOperations interface + CheckRebaseInProgress func(ctx context.Context) error + GetRebaseHead func() (string, error) + InteractiveRebase func(ctx context.Context, onto string) error + IsRebaseInProgress func(ctx context.Context) bool + Rebase func(ctx context.Context, branchName, upstream, oldUpstream string) (RebaseOutcome, error) + RebaseAbort func(ctx context.Context) error + RebaseContinue func(ctx context.Context) (RebaseOutcome, error) + RebaseContinueNoEdit func(ctx context.Context) (RebaseOutcome, error) + type RebaseOutcome struct + RerereResolvedCount int + Result RebaseResult + func AutoContinueRerereRebase(ctx context.Context, r Runner, originalErr error) (RebaseOutcome, []string, error) + type RebaseResult int + const RebaseConflict + const RebaseDone + type RecentCommit struct + Author string + Date time.Time + Kind RecentCommitKind + PRNumber int + SHA string + StackPRNumbers []int + StackScope string + StackSize int + Subject string + type RecentCommitKind string + const RecentCommitKindRegular + const RecentCommitKindStackMerge + type RefOperations interface + DeleteRef func(name string) error + DeleteRefsBatch func(ctx context.Context, refNames []string) error + GetRef func(name string) (string, error) + ListRefs func(prefix string) (map[string]string, error) + UpdateRef func(name, sha string) error + UpdateRefWithLog func(ctx context.Context, refName, sha, message string) error + UpdateRefsBatch func(ctx context.Context, updates []RefUpdate) error + UpdateRefsBatchWithLog func(ctx context.Context, updates []RefUpdate, reflogMessage string) error + VerifyRef func(ctx context.Context, refName string) error + type RefUpdate struct + IsDelete bool + NewSHA string + OldSHA string + RefName string + type RemoteOperations interface + BatchDeleteRemoteMetadataRefs func(ctx context.Context, branches []string) error + DeleteRemoteMetadataRef func(ctx context.Context, branch string) error + DeleteRemoteStackMetaRefs func(ctx context.Context, stackIDs []string) error + Fetch func(ctx context.Context, remote, branch string) error + FetchMetadataRefs func(ctx context.Context) error + FetchRemoteShas func(ctx context.Context, remote string) (map[string]string, error) + FetchStackMetaRefs func(ctx context.Context) error + FindRemoteBranch func(ctx context.Context, remote string) (string, error) + GetRemoteRevision func(branchName string) (string, error) + GetRemoteSha func(remote, branchName string) (string, error) + PullBranch func(ctx context.Context, remote, branchName string) (PullResult, error) + PushBranch func(ctx context.Context, branchName, remote string, opts PushOptions) error + PushMetadataRefs func(ctx context.Context, branches []string) error + PushStackMetaRefs func(ctx context.Context, stackIDs []string) error + TestRemoteRefCompatibility func() error + type Repository struct + func OpenRepository(path string) (*Repository, error) + func (r *Repository) GetBranchNames() ([]string, error) + func (r *Repository) GetCurrentBranch() (string, error) + func (r *Repository) GetReference(name string) (*plumbing.Reference, error) + func (r *Repository) GetRepoRoot() string + func (r *Repository) SetConfigRaw(raw *format.Config) error + type RepositoryReader interface + DiscoverRepoRoot func() (string, error) + GetConfig func(key string) (string, error) + GetConfigAll func(key string) ([]string, error) + GetGitCommonDir func() (string, error) + GetRemote func() string + GetRepoInfo func(ctx context.Context) (string, string, error) + GetRepoRoot func() string + GetUserName func(ctx context.Context) (string, error) + IsInsideRepo func() bool + type RepositoryWriter interface + AddConfigValue func(key, value string) error + EnsureMetadataRefspecConfigured func() error + EnsureStackMetaRefspecConfigured func() error + InitDefaultRepo func() error + SetConfig func(key, value string) error + type ResetOperations interface + HardReset func(ctx context.Context, revision string) error + MixedReset func(ctx context.Context, revision string) error + ResetMerge func(ctx context.Context, revision string) error + SoftReset func(ctx context.Context, revision string) error + type Runner interface + RunGHCommandWithContext func(ctx context.Context, args ...string) (string, error) + RunGitCommandInteractive func(args ...string) error + RunGitCommandRawWithContext func(ctx context.Context, args ...string) (string, error) + RunGitCommandWithContext func(ctx context.Context, args ...string) (string, error) + RunGitCommandWithEnv func(ctx context.Context, env []string, args ...string) (string, error) + SetLogger func(logger DebugLogger) + func NewRunner(logger DebugLogger) Runner + func NewRunnerWithPath(repoRoot string, logger DebugLogger) Runner + func NewTracingRunner(inner Runner, logger DebugLogger) Runner + type StackDescription struct + Description string + Title string + func (sd *StackDescription) IsEmpty() bool + type StackMeta struct + CreatedAt time.Time + CreatedBy string + Description string + ID string + Title string + func (sm *StackMeta) IsEmpty() bool + func (sm *StackMeta) StackDescription() *StackDescription + type StackMetadataOperations interface + DeleteStackMeta func(stackID string) error + GetStackMetaRefSHA func(stackID string) string + ListStackMetas func() (map[string]string, error) + ReadStackMeta func(stackID string) (*StackMeta, error) + WriteStackMeta func(stackID string, meta *StackMeta) error + WriteStackMetaBlob func(meta *StackMeta) (string, error) + type StagingOperations interface + AddAll func(ctx context.Context) error + GetUntrackedFiles func(ctx context.Context) ([]string, error) + HasStagedChanges func(ctx context.Context) (bool, error) + HasUnstagedChanges func(ctx context.Context) (bool, error) + HasUntrackedFiles func(ctx context.Context) (bool, error) + ParseStagedHunks func(ctx context.Context) ([]Hunk, error) + StageAll func(ctx context.Context) error + StageChanges func(ctx context.Context, opts StagingOptions) error + StageHunks func(ctx context.Context, hunks []Hunk) error + StagePatch func(ctx context.Context) error + StageTracked func(ctx context.Context) error + UnstageAll func(ctx context.Context) error + type StagingOptions struct + All bool + Patch bool + Update bool + type StashOperations interface + ListStash func(ctx context.Context) (string, error) + StashPop func(ctx context.Context) error + StashPush func(ctx context.Context, message string) (string, error) + StashPushStaged func(ctx context.Context, message string) (string, error) + type StatusOperations interface + GetReflog func(ctx context.Context, count int, format string) (string, error) + GetStatusPorcelain func(ctx context.Context) (string, error) + HasUncommittedChanges func(ctx context.Context) bool + type TraceLogger interface + Trace func(op string, durationMicros int64, success bool, err error, attrs ...slog.Attr) + type WorktreeMeta struct + AnchorBranch string + CreatedAt time.Time + MainRepoDir string + Name string + Path string + type WorktreeOperations interface + AddWorktree func(ctx context.Context, path string, branch string, detach bool) error + AddWorktreeWithOptions func(ctx context.Context, path string, branch string, detach bool, noCheckout bool) error + GetWorktreeCurrentBranch func(ctx context.Context, worktreePath string) (string, error) + GetWorktreePathForBranch func(ctx context.Context, branchName string) (string, error) + ListWorktrees func(ctx context.Context) ([]string, error) + PruneWorktrees func(ctx context.Context) error + RemoveWorktree func(ctx context.Context, path string) error + ResetWorktreeWorkingDir func(ctx context.Context, worktreePath string) error + WorktreeHasUncommittedChanges func(ctx context.Context, worktreePath string) (bool, error) + type WorktreeRegistryOperations interface + DeleteWorktreeMeta func(stackRoot string) error + ListWorktreeMetas func() (map[string]*WorktreeMeta, error) + ReadWorktreeMeta func(stackRoot string) (*WorktreeMeta, error) + WriteWorktreeMeta func(stackRoot string, meta *WorktreeMeta) error