worktree

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package worktree provides git worktree automation for isolated run environments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(ctx context.Context, repoPath string) error

Cleanup removes all agentpair worktrees from a repository.

func GenerateBranchName

func GenerateBranchName(runID int) string

GenerateBranchName creates a branch name for a run.

func GenerateWorktreePath

func GenerateWorktreePath(repoPath string, runID int) string

GenerateWorktreePath creates a worktree path for a run.

func GetRepoRoot

func GetRepoRoot(path string) (string, error)

GetRepoRoot returns the root of the git repository.

func IsGitRepo

func IsGitRepo(path string) bool

IsGitRepo checks if a path is a git repository.

func IsGitWorktree

func IsGitWorktree(path string) bool

IsGitWorktree checks if a path is a git worktree.

Types

type Worktree

type Worktree struct {
	// contains filtered or unexported fields
}

Worktree represents a git worktree.

func New

func New(repoPath, worktreePath, branch string) *Worktree

New creates a new worktree manager.

func (*Worktree) Branch

func (w *Worktree) Branch() string

Branch returns the worktree branch name.

func (*Worktree) Create

func (w *Worktree) Create(ctx context.Context) error

Create creates the git worktree.

func (*Worktree) Exists

func (w *Worktree) Exists() bool

Exists checks if the worktree exists.

func (*Worktree) Path

func (w *Worktree) Path() string

Path returns the worktree path.

func (*Worktree) Remove

func (w *Worktree) Remove(ctx context.Context, force bool) error

Remove removes the git worktree.

func (*Worktree) WasCreated

func (w *Worktree) WasCreated() bool

WasCreated returns true if this instance created the worktree.

type WorktreeInfo

type WorktreeInfo struct {
	Path     string
	HEAD     string
	Branch   string
	Bare     bool
	Detached bool
}

WorktreeInfo contains information about a worktree.

func ListWorktrees

func ListWorktrees(repoPath string) ([]WorktreeInfo, error)

ListWorktrees lists all worktrees for a repository.

Jump to

Keyboard shortcuts

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