cli

package
v1.50.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CleanupKindWorktree = "worktree"
	CleanupKindBranch   = "branch"
	CleanupKindOrphan   = "orphan"
)

Cleanup item kinds as emitted in the structured summary.

Variables

This section is empty.

Functions

func CreateFromBranch

func CreateFromBranch(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, branchName, worktreeName string, withChange, silent bool) (string, error)

CreateFromBranch creates a worktree from a branch name.

func CreateFromBranchWithFS added in v1.30.0

func CreateFromBranchWithFS(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, branchName, worktreeName string, withChange, silent bool, fs OSFilesystem) (string, error)

CreateFromBranchWithFS creates a worktree from a branch name using the provided filesystem.

func CreateFromIssue added in v1.34.0

func CreateFromIssue(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, issueNumber int, baseBranch string, noWorkspace, silent bool) (string, error)

CreateFromIssue creates a worktree from an issue number.

func CreateFromIssueWithFS added in v1.34.0

func CreateFromIssueWithFS(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, issueNumber int, baseBranch string, noWorkspace, silent bool, fs OSFilesystem) (string, error)

CreateFromIssueWithFS creates a worktree from an issue number using the provided filesystem.

func CreateFromPR

func CreateFromPR(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, prNumber int, noWorkspace, silent bool) (string, error)

CreateFromPR creates a worktree from a PR number.

func CreateFromPRWithFS added in v1.30.0

func CreateFromPRWithFS(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, prNumber int, noWorkspace, silent bool, fs OSFilesystem) (string, error)

CreateFromPRWithFS creates a worktree from a PR number using the provided filesystem.

func DeleteWorktree

func DeleteWorktree(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, worktreePath string, deleteBranch, silent bool) error

DeleteWorktree deletes a worktree. If worktreePath is empty, lists available worktrees.

func FindWorktreeByPathOrName added in v1.37.0

func FindWorktreeByPathOrName(pathOrName string, worktrees []*models.WorktreeInfo, worktreeDir, repoName, mainWorktreePath string) (*models.WorktreeInfo, error)

FindWorktreeByPathOrName finds a worktree by its path or name.

func IsRepoLocal added in v1.45.1

func IsRepoLocal(worktreeDir, mainWorktreePath string) bool

IsRepoLocal reports whether worktreeDir is inside mainWorktreePath, indicating that worktrees are stored within the repository itself.

func NoteEdit added in v1.42.0

func NoteEdit(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, worktreePathOrName, inputFile string) error

NoteEdit edits the note for a worktree. If inputFile is "-", reads from stdin. If inputFile is non-empty, reads from that file. Otherwise opens $EDITOR.

func NoteGet added in v1.44.0

func NoteGet(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, worktreePathOrName string) (*models.WorktreeNote, string, error)

NoteGet retrieves the note for a worktree without printing it. Returns the note (empty if none exists), the worktree path, and any error.

func NoteSet added in v1.44.0

func NoteSet(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, worktreePathOrName string, note models.WorktreeNote) error

NoteSet writes note metadata for a worktree without opening an editor. Only non-zero fields in note are applied; existing fields not mentioned are preserved.

func NoteShow added in v1.42.0

func NoteShow(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, worktreePathOrName string) error

NoteShow prints the note text for a worktree to stdout.

func RenameWorktree added in v1.37.0

func RenameWorktree(ctx context.Context, gitSvc gitService, cfg *config.AppConfig, worktreePath, newName string, silent bool) error

RenameWorktree renames a worktree. The branch is renamed only when the current worktree name and branch name are the same.

func SelectIssueInteractive added in v1.34.0

func SelectIssueInteractive(ctx context.Context, gitSvc gitService, query string, stdin io.Reader, stderr io.Writer) (int, error)

SelectIssueInteractive presents an interactive issue selector (fzf when available, numbered list otherwise).

func SelectIssueInteractiveFromStdio added in v1.34.0

func SelectIssueInteractiveFromStdio(ctx context.Context, gitSvc gitService, query string) (int, error)

SelectIssueInteractiveFromStdio wraps SelectIssueInteractive with os.Stdin/os.Stderr.

func SelectPRInteractive added in v1.34.0

func SelectPRInteractive(ctx context.Context, gitSvc gitService, query string, stdin io.Reader, stderr io.Writer) (int, error)

SelectPRInteractive presents an interactive PR selector (fzf when available, numbered list otherwise).

func SelectPRInteractiveFromStdio added in v1.34.0

func SelectPRInteractiveFromStdio(ctx context.Context, gitSvc gitService, query string) (int, error)

SelectPRInteractiveFromStdio wraps SelectPRInteractive with os.Stdin/os.Stderr.

Types

type CleanupItem added in v1.49.0

type CleanupItem struct {
	Kind          string
	Path          string
	Branch        string
	Source        string
	BranchDeleted bool
	Skipped       bool
	SkipReason    string
	Failed        bool
	Error         string
}

CleanupItem describes a single candidate acted upon during cleanup.

type CleanupSummary added in v1.49.0

type CleanupSummary struct {
	Worktrees int
	Branches  int
	Orphans   int
	Skipped   int
	Failures  int
	Items     []CleanupItem
}

CleanupSummary reports the aggregate counts and per-item detail of a cleanup run so callers can render human-readable or machine-readable output.

func Cleanup added in v1.49.0

func Cleanup(
	ctx context.Context,
	gitSvc cleanupGitService,
	cfg *config.AppConfig,
	all bool,
	jsonOutput bool,
	stdin io.Reader,
	stderr io.Writer,
) (CleanupSummary, error)

Cleanup finds merged worktrees, configured stale branches, and orphaned worktree directories. It prompts for a numbered selection unless all is true. When jsonOutput is true it requires all (non-interactive) and returns a structured summary for machine-readable rendering while suppressing progress messages such as terminate command notices.

type OSFilesystem added in v1.30.0

type OSFilesystem interface {
	Stat(name string) (os.FileInfo, error)
	MkdirAll(path string, perm os.FileMode) error
	Getwd() (string, error)
}

OSFilesystem abstracts filesystem operations for dependency injection.

var DefaultFS OSFilesystem = RealFilesystem{}

DefaultFS is the default filesystem implementation using the real os package.

type RealFilesystem added in v1.30.0

type RealFilesystem struct{}

RealFilesystem implements OSFilesystem using the real os package.

func (RealFilesystem) Getwd added in v1.30.0

func (RealFilesystem) Getwd() (string, error)

Getwd wraps os.Getwd.

func (RealFilesystem) MkdirAll added in v1.30.0

func (RealFilesystem) MkdirAll(path string, perm os.FileMode) error

MkdirAll wraps os.MkdirAll.

func (RealFilesystem) Stat added in v1.30.0

func (RealFilesystem) Stat(name string) (os.FileInfo, error)

Stat wraps os.Stat.

Jump to

Keyboard shortcuts

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