Documentation
¶
Index ¶
- Variables
- func AddLabel(repoPath, label string) error
- func BranchExists(branch string) (bool, error)
- func CanRepairWorktree(worktreePath string) bool
- func CheckGit() error
- func ClearBranchNote(repoPath, branch string) error
- func ClearLabels(repoPath string) error
- func DeleteLocalBranch(repoPath, branch string, force bool) error
- func ExtractRepoNameFromURL(url string) string
- func FetchBranch(repoPath, branch string) error
- func FetchDefaultBranch(repoPath string) error
- func FindAllRepos(basePath string) ([]string, error)
- func FindRepoByName(basePath, name string) (string, error)
- func FindReposByLabel(scanDir, label string) ([]string, error)
- func FindSimilarRepos(basePath, search string) []string
- func GetAllBranchConfig(repoPath string) (notes map[string]string, upstreams map[string]bool)
- func GetBranchCreatedTime(repoPath, branch string) (time.Time, error)
- func GetBranchNote(repoPath, branch string) (string, error)
- func GetBranchWorktree(branch string) (string, error)
- func GetCommitCount(repoPath, branch string) (int, error)
- func GetCommitsBehind(repoPath, branch string) (int, error)
- func GetCurrentBranch(path string) (string, error)
- func GetCurrentRepoMainPath() string
- func GetDefaultBranch(repoPath string) string
- func GetLabels(repoPath string) ([]string, error)
- func GetLastCommitRelative(path string) (string, error)
- func GetLastCommitTime(path string) (time.Time, error)
- func GetMainRepoPath(worktreePath string) (string, error)
- func GetMergedBranches(repoPath string) map[string]bool
- func GetOriginURL(repoPath string) (string, error)
- func GetRepoDisplayName(repoPath string) string
- func GetRepoFolderName() (string, error)
- func GetRepoName() (string, error)
- func GetRepoNameFrom(repoPath string) (string, error)
- func GetShortCommitHash(path string) (string, error)
- func GetUpstreamBranch(repoPath, branch string) string
- func GroupWorktreesByRepo(worktrees []Worktree) map[string][]Worktree
- func HasLabel(repoPath, label string) (bool, error)
- func IsBranchMerged(repoPath, branch string) (bool, error)
- func IsDirty(path string) bool
- func IsInsideRepo() bool
- func IsWorktree(path string) bool
- func IsWorktreeLinkValid(worktreePath string) bool
- func ListPrunableWorktrees(repoPath string) ([]string, error)
- func MoveWorktree(worktree Worktree, newPath string, force bool) error
- func ParseRepoArg(repo string) (org, name string)
- func PruneWorktrees(repoPath string) error
- func RemoveLabel(repoPath, label string) error
- func RemoveWorktree(worktree Worktree, force bool) error
- func RepairWorktree(repoPath, worktreePath string) error
- func RepairWorktreesFromRepo(repoPath string) error
- func SetBranchNote(repoPath, branch, note string) error
- func SetLabels(repoPath string, labels []string) error
- type CreateWorktreeResult
- func AddWorktree(basePath, branch, worktreeFmt string, createNew bool, baseRef string) (*CreateWorktreeResult, error)
- func CreateWorktreeFrom(repoPath, basePath, branch, worktreeFmt, baseRef string) (*CreateWorktreeResult, error)
- func OpenWorktreeFrom(absRepoPath, basePath, branch, worktreeFmt string) (*CreateWorktreeResult, error)
- type DiffStats
- type Worktree
- type WorktreeInfo
Constants ¶
This section is empty.
Variables ¶
var ErrGitNotFound = fmt.Errorf("git not found: please install git (https://git-scm.com)")
ErrGitNotFound indicates git is not installed or not in PATH
Functions ¶
func BranchExists ¶
BranchExists checks if a local branch exists
func CanRepairWorktree ¶ added in v0.4.0
CanRepairWorktree checks if a worktree can potentially be repaired. Returns true if .git file exists but links are broken.
func ClearBranchNote ¶
ClearBranchNote removes the note (description) from a branch
func ClearLabels ¶
ClearLabels removes all labels from a repository
func DeleteLocalBranch ¶
DeleteLocalBranch deletes a local branch
func ExtractRepoNameFromURL ¶
ExtractRepoNameFromURL extracts the repository name from a git URL
func FetchBranch ¶
FetchBranch fetches a specific branch from origin
func FetchDefaultBranch ¶
FetchDefaultBranch fetches the default branch (main/master) from origin
func FindAllRepos ¶
FindAllRepos returns paths to all git repositories in basePath (direct children only)
func FindRepoByName ¶
FindRepoByName searches direct children of basePath for a git repo with the given name. First checks for exact folder name match with matching origin, then searches all repos by origin. Returns the full path if found, or an error if not found.
func FindReposByLabel ¶
FindReposByLabel scans a directory for repos with the given label Returns paths to matching repositories
func FindSimilarRepos ¶
FindSimilarRepos returns repo names in basePath that contain the search string. Useful for providing suggestions when a repo is not found.
func GetAllBranchConfig ¶
GetAllBranchConfig returns branch notes and upstreams for a repository in one call. Uses: `git config --get-regexp 'branch\.'` Returns: notes map (branch -> note), upstreams map (branch -> upstream ref)
func GetBranchCreatedTime ¶
GetBranchCreatedTime returns when the branch was created (first commit on branch) Falls back to first commit time if reflog is unavailable
func GetBranchNote ¶
GetBranchNote returns the note (description) for a branch Returns empty string if no note is set
func GetBranchWorktree ¶
GetBranchWorktree returns the worktree path if branch is checked out, empty string if not
func GetCommitCount ¶
GetCommitCount returns number of commits ahead of the default branch
func GetCommitsBehind ¶
GetCommitsBehind returns number of commits behind the default branch
func GetCurrentBranch ¶
GetCurrentBranch returns the current branch name Returns "(detached)" for detached HEAD state
func GetCurrentRepoMainPath ¶
func GetCurrentRepoMainPath() string
GetCurrentRepoMainPath returns the main repository path from cwd Works whether you're in the main repo or a worktree Returns empty string if not in a git repo
func GetDefaultBranch ¶
GetDefaultBranch returns the default branch name for the remote (e.g., "main" or "master")
func GetLabels ¶
GetLabels returns the labels for a repository Returns empty slice if no labels are set
func GetLastCommitRelative ¶
GetLastCommitRelative returns relative time of last commit
func GetLastCommitTime ¶ added in v0.2.0
GetLastCommitTime returns the unix timestamp of the last commit
func GetMainRepoPath ¶
GetMainRepoPath extracts main repo path from .git file in worktree
func GetMergedBranches ¶
GetMergedBranches returns a set of branches that are merged into the default branch. Uses a single git call: `git branch --merged origin/<default>`
func GetOriginURL ¶
GetOriginURL gets the origin URL for a repository
func GetRepoDisplayName ¶ added in v0.4.0
GetRepoDisplayName returns the repo name from origin URL, falling back to folder name.
func GetRepoFolderName ¶
GetRepoFolderName returns the actual folder name of the git repo on disk Uses git rev-parse --show-toplevel to get the root directory
func GetRepoName ¶
GetRepoName extracts the repository name from the origin URL
func GetRepoNameFrom ¶
GetRepoNameFrom extracts the repository name from the origin URL of a repo at the given path
func GetShortCommitHash ¶
GetShortCommitHash returns the short (7 char) commit hash for HEAD in a worktree
func GetUpstreamBranch ¶
GetUpstreamBranch returns the remote branch name for a local branch. Returns empty string if no upstream is configured.
func GroupWorktreesByRepo ¶
GroupWorktreesByRepo groups worktrees by their main repository
func IsBranchMerged ¶
IsBranchMerged checks if a branch is merged into the default branch (main/master)
func IsInsideRepo ¶
func IsInsideRepo() bool
IsInsideRepo returns true if the current working directory is inside a git repository
func IsWorktree ¶
IsWorktree returns true if path is a git worktree (not main repo) Worktrees have .git as a file pointing to the main repo, while main repos have .git as a directory.
func IsWorktreeLinkValid ¶ added in v0.4.0
IsWorktreeLinkValid checks if a worktree's bidirectional link is valid. Returns true if both the .git file in worktree and gitdir in main repo exist and match.
func ListPrunableWorktrees ¶ added in v0.4.0
ListPrunableWorktrees returns worktree paths that git considers stale. Uses `git worktree prune --dry-run` and parses the output.
func MoveWorktree ¶
MoveWorktree moves a git worktree to a new path
func ParseRepoArg ¶
ParseRepoArg splits a repo argument into org and name components. "org/repo" returns ("org", "repo") "repo" returns ("", "repo")
func PruneWorktrees ¶
PruneWorktrees prunes stale worktree references
func RemoveLabel ¶
RemoveLabel removes a label from a repository
func RemoveWorktree ¶
RemoveWorktree removes a git worktree
func RepairWorktree ¶ added in v0.4.0
RepairWorktree attempts to repair broken links for a single worktree. Uses `git worktree repair <path>` from the main repo.
func RepairWorktreesFromRepo ¶ added in v0.4.0
RepairWorktreesFromRepo repairs all worktrees for a repository. Uses `git worktree repair` without arguments to repair all.
func SetBranchNote ¶
SetBranchNote sets a note (description) on a branch
Types ¶
type CreateWorktreeResult ¶
CreateWorktreeResult contains the result of creating a worktree
func AddWorktree ¶
func AddWorktree(basePath, branch, worktreeFmt string, createNew bool, baseRef string) (*CreateWorktreeResult, error)
AddWorktree creates a git worktree at basePath/<formatted-name> If createNew is true, creates a new branch (-b flag); otherwise checks out existing branch baseRef is the starting point for new branches (e.g., "origin/main")
func CreateWorktreeFrom ¶
func CreateWorktreeFrom(repoPath, basePath, branch, worktreeFmt, baseRef string) (*CreateWorktreeResult, error)
CreateWorktreeFrom creates a worktree from a specified repository path Used when working with a repo that isn't the current working directory baseRef is the starting point for the new branch (e.g., "origin/main", or empty for HEAD)
func OpenWorktreeFrom ¶
func OpenWorktreeFrom(absRepoPath, basePath, branch, worktreeFmt string) (*CreateWorktreeResult, error)
OpenWorktreeFrom creates a worktree for an existing branch in a specified repo
type DiffStats ¶
DiffStats contains diff statistics
func GetDiffStats ¶
GetDiffStats returns additions, deletions, and files changed vs default branch
type Worktree ¶
type Worktree struct {
Path string `json:"path"`
Branch string `json:"branch"`
MainRepo string `json:"main_repo"`
RepoName string `json:"repo_name"`
OriginURL string `json:"origin_url"`
IsMerged bool `json:"is_merged"`
CommitCount int `json:"commit_count"`
IsDirty bool `json:"is_dirty"` // only populated when includeDirty=true
HasUpstream bool `json:"has_upstream"`
LastCommit string `json:"last_commit"`
LastCommitTime time.Time `json:"last_commit_time"` // for sorting by commit date
Note string `json:"note,omitempty"`
}
Worktree represents a git worktree with its status
func GetWorktreeInfo ¶
GetWorktreeInfo returns info for a single worktree at the given path
func ListWorktrees ¶
ListWorktrees scans a directory for git worktrees with batched git calls per repo. If includeDirty is true, checks each worktree for dirty status (adds subprocess calls). For 10 worktrees across 2 repos: ~8 calls (list) or ~18 calls with dirty checks (tidy).
type WorktreeInfo ¶
type WorktreeInfo struct {
Path string
Branch string
CommitHash string // Full hash from git, caller can truncate
}
WorktreeInfo contains basic worktree information from git worktree list.
func ListWorktreesFromRepo ¶
func ListWorktreesFromRepo(repoPath string) ([]WorktreeInfo, error)
ListWorktreesFromRepo returns all worktrees for a repository using git worktree list --porcelain. This is much faster than querying each worktree individually.