worktree

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitMu sync.Mutex

GitMu serializes git worktree operations to prevent concurrent index.lock conflicts.

Functions

func AgeDays

func AgeDays(path string) (int, error)

AgeDays returns the age of a worktree in days based on its last commit.

func AgeHours

func AgeHours(path string) (int, error)

AgeHours returns the age of a worktree in hours based on its last commit.

func CleanAllStaleLocks

func CleanAllStaleLocks(cfg *config.Config)

CleanAllStaleLocks cleans stale locks across all known repos.

func CleanStaleLocks

func CleanStaleLocks(cfg *config.Config, repo string)

CleanStaleLocks removes stale index.lock files from worktrees of the given repo. A lock is considered stale if the PID inside it is no longer running.

func LastActivity

func LastActivity(path string) (time.Time, error)

LastActivity returns the date of the last commit in the worktree.

func ParseBranchFromName

func ParseBranchFromName(name string) string

ParseBranchFromName extracts the branch suffix from a worktree directory name. e.g., "mono-feature-branch" -> "feature-branch"

func ParseRepoFromName

func ParseRepoFromName(name string) string

ParseRepoFromName extracts the repo short name from a worktree directory name. e.g., "mono-pr-1234" -> "mono"

Types

type Stats

type Stats struct {
	Total     int            `json:"total"`
	PRReviews int            `json:"pr_reviews"`
	Features  int            `json:"features"`
	ByRepo    map[string]int `json:"by_repo"`
}

Stats holds worktree statistics.

func GetStats

func GetStats(cfg *config.Config) (*Stats, error)

GetStats computes statistics across all worktrees.

type Type

type Type string

Type classifies a worktree.

const (
	TypePRReview Type = "pr-review"
	TypeFeature  Type = "feature"
)

func Classify

func Classify(name string) (Type, int)

Classify determines if a worktree name represents a PR review or feature work.

type Worktree

type Worktree struct {
	Path     string `json:"path"`
	Name     string `json:"name"`
	Branch   string `json:"branch"`
	Type     Type   `json:"type"`
	PRNumber int    `json:"pr_number,omitempty"`
	Repo     string `json:"repo"`
}

Worktree represents a discovered git worktree.

func ListAll

func ListAll(cfg *config.Config) ([]Worktree, error)

ListAll lists worktrees across all configured repositories.

func ListForRepo

func ListForRepo(cfg *config.Config, repo string) ([]Worktree, error)

ListForRepo lists all worktrees for a given repository using `git worktree list`.

Jump to

Keyboard shortcuts

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