Documentation
¶
Index ¶
- func CreateWorktree(repoPath, worktreePath, branch, base string) error
- func DeleteBranch(repoPath, branch string) error
- func DiscoverWorktrees(project *data.Project) ([]data.Worktree, error)
- func GetCurrentBranch(path string) (string, error)
- func GetRemoteURL(path, remote string) (string, error)
- func GetRepoRoot(path string) (string, error)
- func IsGitRepository(path string) bool
- func RemoveWorktree(repoPath, worktreePath string) error
- func RunGit(dir string, args ...string) (string, error)
- type Commit
- type CommitLog
- type FileStatus
- type FileWatcher
- type GitError
- type StatusCache
- type StatusManager
- func (m *StatusManager) GetCached(root string) *StatusResult
- func (m *StatusManager) Invalidate(root string)
- func (m *StatusManager) InvalidateAll()
- func (m *StatusManager) RefreshAll()
- func (m *StatusManager) RequestRefresh(root string)
- func (m *StatusManager) SetCacheTTL(ttl time.Duration)
- func (m *StatusManager) SetDebounceDelay(delay time.Duration)
- func (m *StatusManager) UpdateCache(root string, status *StatusResult)
- type StatusResult
- type WorktreeEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateWorktree ¶
CreateWorktree creates a new git worktree
func DeleteBranch ¶
DeleteBranch deletes a git branch
func DiscoverWorktrees ¶
DiscoverWorktrees discovers all worktrees for a project and converts them to data.Worktree
func GetCurrentBranch ¶
GetCurrentBranch returns the current branch name
func GetRemoteURL ¶
GetRemoteURL returns the URL of the specified remote
func GetRepoRoot ¶
GetRepoRoot returns the root directory of the git repository
func IsGitRepository ¶
IsGitRepository checks if the given path is a git repository
func RemoveWorktree ¶
RemoveWorktree removes a git worktree
Types ¶
type Commit ¶
type Commit struct {
ShortHash string // Abbreviated SHA (7 chars)
FullHash string // Full SHA (40 chars)
Subject string // First line of commit message
Author string // Author name
Date string // Relative date (e.g., "2 hours ago")
GraphLine string // ASCII graph prefix (e.g., "* ", "| * ", etc.)
Refs string // Branch/tag names (e.g., "HEAD -> main, origin/main")
}
Commit represents a parsed git commit with graph information
type CommitLog ¶
type CommitLog struct {
Commits []Commit
}
CommitLog represents the result of parsing git log output
type FileStatus ¶
type FileStatus struct {
Code string // Two-character status code (e.g., "M ", " M", "??", "A ")
Path string // File path relative to repo root
}
FileStatus represents the status of a single file
func (*FileStatus) DisplayCode ¶
func (f *FileStatus) DisplayCode() string
DisplayCode returns a user-friendly display code For untracked files, returns "A " instead of "??" to indicate they are additions
func (*FileStatus) IsAdded ¶
func (f *FileStatus) IsAdded() bool
IsAdded checks if a file status represents an addition
func (*FileStatus) IsDeleted ¶
func (f *FileStatus) IsDeleted() bool
IsDeleted checks if a file status represents a deletion
func (*FileStatus) IsDirectory ¶
func (f *FileStatus) IsDirectory() bool
IsDirectory checks if the path is a directory (ends with /)
func (*FileStatus) IsModified ¶
func (f *FileStatus) IsModified() bool
IsModified checks if a file status represents a modification
func (*FileStatus) IsUntracked ¶
func (f *FileStatus) IsUntracked() bool
IsUntracked checks if a file is untracked
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher watches git directories for changes and triggers status refreshes
func NewFileWatcher ¶
func NewFileWatcher(onChanged func(root string)) (*FileWatcher, error)
NewFileWatcher creates a new file watcher
func (*FileWatcher) Close ¶
func (fw *FileWatcher) Close() error
Close stops the watcher and releases resources
func (*FileWatcher) IsWatching ¶
func (fw *FileWatcher) IsWatching(root string) bool
IsWatching checks if a worktree is being watched
func (*FileWatcher) Unwatch ¶
func (fw *FileWatcher) Unwatch(root string)
Unwatch stops watching a worktree
func (*FileWatcher) Watch ¶
func (fw *FileWatcher) Watch(root string) error
Watch starts watching a worktree for git changes
type StatusCache ¶
type StatusCache struct {
Status *StatusResult
FetchedAt time.Time
}
StatusCache holds cached git status with TTL
type StatusManager ¶
type StatusManager struct {
// contains filtered or unexported fields
}
StatusManager manages async git status with caching and debouncing
func NewStatusManager ¶
func NewStatusManager(onUpdate func(root string, status *StatusResult, err error)) *StatusManager
NewStatusManager creates a new status manager
func (*StatusManager) GetCached ¶
func (m *StatusManager) GetCached(root string) *StatusResult
GetCached returns the cached status for a worktree, or nil if not cached/expired
func (*StatusManager) Invalidate ¶
func (m *StatusManager) Invalidate(root string)
Invalidate removes a worktree from the cache
func (*StatusManager) InvalidateAll ¶
func (m *StatusManager) InvalidateAll()
InvalidateAll clears the entire cache
func (*StatusManager) RefreshAll ¶
func (m *StatusManager) RefreshAll()
RefreshAll refreshes status for all cached worktrees
func (*StatusManager) RequestRefresh ¶
func (m *StatusManager) RequestRefresh(root string)
RequestRefresh requests an async status refresh for a worktree Uses debouncing to prevent too frequent refreshes
func (*StatusManager) SetCacheTTL ¶
func (m *StatusManager) SetCacheTTL(ttl time.Duration)
SetCacheTTL sets the cache time-to-live
func (*StatusManager) SetDebounceDelay ¶
func (m *StatusManager) SetDebounceDelay(delay time.Duration)
SetDebounceDelay sets the debounce delay
func (*StatusManager) UpdateCache ¶
func (m *StatusManager) UpdateCache(root string, status *StatusResult)
UpdateCache directly updates the cache with a status result (no fetch)
type StatusResult ¶
type StatusResult struct {
Files []FileStatus
Clean bool
}
StatusResult holds the parsed git status
func GetStatus ¶
func GetStatus(repoPath string) (*StatusResult, error)
GetStatus returns the git status for a repository Uses -u flag to show individual files in untracked directories
func (*StatusResult) GetDirtyCount ¶
func (s *StatusResult) GetDirtyCount() int
GetDirtyCount returns the number of modified files
func (*StatusResult) GetStatusSummary ¶
func (s *StatusResult) GetStatusSummary() string
GetStatusSummary returns a summary string for the status
type WorktreeEntry ¶
WorktreeEntry represents a raw worktree entry from git
func ListWorktrees ¶
func ListWorktrees(repoPath string) ([]WorktreeEntry, error)
ListWorktrees lists all worktrees for a repository