Documentation
¶
Index ¶
- func CleanupWorktrees() error
- func IsGitRepo(path string) bool
- type DiffStats
- type GitWorktree
- func NewGitWorktree(repoPath string, sessionName string) (tree *GitWorktree, branchname string, err error)
- func NewGitWorktreeFromCommitSHA(repoPath, sessionName, branchName, commitSHA string) (*GitWorktree, string, error)
- func NewGitWorktreeFromExisting(existingWorktreePath string, sessionName string) (*GitWorktree, error)
- func NewGitWorktreeFromExistingWithExecutor(existingWorktreePath string, sessionName string, cmdExec executor.Executor) (*GitWorktree, error)
- func NewGitWorktreeFromStorage(repoPath string, worktreePath string, sessionName string, branchName string, ...) *GitWorktree
- func NewGitWorktreeFromStorageWithExecutor(repoPath string, worktreePath string, sessionName string, branchName string, ...) *GitWorktree
- func NewGitWorktreeWithBranch(repoPath string, sessionName string, customBranch string) (tree *GitWorktree, branchname string, err error)
- func NewGitWorktreeWithBranchAndExecutor(repoPath string, sessionName string, customBranch string, ...) (tree *GitWorktree, branchname string, err error)
- func (g *GitWorktree) Cleanup() error
- func (g *GitWorktree) CommitChanges(commitMessage string) error
- func (g *GitWorktree) Diff() *DiffStats
- func (g *GitWorktree) GetBaseCommitSHA() string
- func (g *GitWorktree) GetBranchName() string
- func (g *GitWorktree) GetRepoName() string
- func (g *GitWorktree) GetRepoPath() string
- func (g *GitWorktree) GetWorktreePath() string
- func (g *GitWorktree) InvalidateDirtyCache()
- func (g *GitWorktree) IsBranchCheckedOut() (bool, error)
- func (g *GitWorktree) IsDirty() (bool, error)
- func (g *GitWorktree) IsDirtyWithHint(claudeActive bool) (bool, error)
- func (g *GitWorktree) OpenBranchURL() error
- func (g *GitWorktree) Prune() error
- func (g *GitWorktree) PushChanges(commitMessage string, open bool) error
- func (g *GitWorktree) Remove() error
- func (g *GitWorktree) Setup() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupWorktrees ¶
func CleanupWorktrees() error
CleanupWorktrees removes all worktrees and their associated branches
Types ¶
type DiffStats ¶
type DiffStats struct {
// Content is the full diff content
Content string
// Added is the number of added lines
Added int
// Removed is the number of removed lines
Removed int
// Error holds any error that occurred during diff computation
// This allows propagating setup errors (like missing base commit) without breaking the flow
Error error
}
DiffStats holds statistics about the changes in a diff
type GitWorktree ¶
type GitWorktree struct {
// contains filtered or unexported fields
}
GitWorktree manages git worktree operations for a session
func NewGitWorktree ¶
func NewGitWorktree(repoPath string, sessionName string) (tree *GitWorktree, branchname string, err error)
NewGitWorktree creates a new GitWorktree instance
func NewGitWorktreeFromCommitSHA ¶
func NewGitWorktreeFromCommitSHA(repoPath, sessionName, branchName, commitSHA string) (*GitWorktree, string, error)
NewGitWorktreeFromCommitSHA creates a new GitWorktree that will branch from the given commitSHA when Setup() is called, instead of branching from the current HEAD. This is used by ForkFromCheckpoint to recreate the exact git state at checkpoint time.
func NewGitWorktreeFromExisting ¶
func NewGitWorktreeFromExisting(existingWorktreePath string, sessionName string) (*GitWorktree, error)
NewGitWorktreeFromExisting creates a GitWorktree from an existing worktree path This is used when connecting to worktrees that were created manually or by deleted sessions
func NewGitWorktreeFromExistingWithExecutor ¶
func NewGitWorktreeFromExistingWithExecutor(existingWorktreePath string, sessionName string, cmdExec executor.Executor) (*GitWorktree, error)
NewGitWorktreeFromExistingWithExecutor creates a GitWorktree from an existing worktree path with an optional executor.
func NewGitWorktreeFromStorageWithExecutor ¶
func NewGitWorktreeFromStorageWithExecutor(repoPath string, worktreePath string, sessionName string, branchName string, baseCommitSHA string, cmdExec executor.Executor) *GitWorktree
NewGitWorktreeFromStorageWithExecutor creates a GitWorktree from stored data with an optional executor. If cmdExec is nil, a default executor is used.
func NewGitWorktreeWithBranch ¶
func NewGitWorktreeWithBranch(repoPath string, sessionName string, customBranch string) (tree *GitWorktree, branchname string, err error)
NewGitWorktreeWithBranch creates a new GitWorktree instance with an optional custom branch name
func NewGitWorktreeWithBranchAndExecutor ¶
func NewGitWorktreeWithBranchAndExecutor(repoPath string, sessionName string, customBranch string, cmdExec executor.Executor) (tree *GitWorktree, branchname string, err error)
NewGitWorktreeWithBranchAndExecutor creates a new GitWorktree with optional branch name and executor. If cmdExec is nil, a default executor is used.
func (*GitWorktree) Cleanup ¶
func (g *GitWorktree) Cleanup() error
Cleanup removes the worktree and associated branch
func (*GitWorktree) CommitChanges ¶
func (g *GitWorktree) CommitChanges(commitMessage string) error
CommitChanges commits changes locally without pushing to remote
func (*GitWorktree) Diff ¶
func (g *GitWorktree) Diff() *DiffStats
Diff returns the git diff between the worktree and the base branch along with statistics
func (*GitWorktree) GetBaseCommitSHA ¶
func (g *GitWorktree) GetBaseCommitSHA() string
GetBaseCommitSHA returns the base commit SHA for the worktree
func (*GitWorktree) GetBranchName ¶
func (g *GitWorktree) GetBranchName() string
GetBranchName returns the name of the branch associated with this worktree
func (*GitWorktree) GetRepoName ¶
func (g *GitWorktree) GetRepoName() string
GetRepoName returns the name of the repository (last part of the repoPath).
func (*GitWorktree) GetRepoPath ¶
func (g *GitWorktree) GetRepoPath() string
GetRepoPath returns the path to the repository
func (*GitWorktree) GetWorktreePath ¶
func (g *GitWorktree) GetWorktreePath() string
GetWorktreePath returns the path to the worktree
func (*GitWorktree) InvalidateDirtyCache ¶ added in v1.22.0
func (g *GitWorktree) InvalidateDirtyCache()
InvalidateDirtyCache clears the IsDirty cache so the next call re-runs git status. Call this whenever worktree state changes outside of Claude's control (e.g. after a manual commit, after running git operations, or in tests after writing files directly).
func (*GitWorktree) IsBranchCheckedOut ¶
func (g *GitWorktree) IsBranchCheckedOut() (bool, error)
IsBranchCheckedOut checks if the instance branch is currently checked out
func (*GitWorktree) IsDirty ¶
func (g *GitWorktree) IsDirty() (bool, error)
IsDirty checks if the worktree has uncommitted changes. Results are cached for isDirtyCacheTTL (15 s) to avoid spawning a subprocess on every call.
func (*GitWorktree) IsDirtyWithHint ¶ added in v1.22.0
func (g *GitWorktree) IsDirtyWithHint(claudeActive bool) (bool, error)
IsDirtyWithHint checks if the worktree has uncommitted changes. When claudeActive is true the subprocess is skipped entirely and the cached value is returned (or false if no cached value is available yet), because Claude never modifies worktree state while it is actively generating output.
func (*GitWorktree) OpenBranchURL ¶
func (g *GitWorktree) OpenBranchURL() error
OpenBranchURL opens the branch URL in the default browser
func (*GitWorktree) Prune ¶
func (g *GitWorktree) Prune() error
Prune removes all working tree administrative files and directories
func (*GitWorktree) PushChanges ¶
func (g *GitWorktree) PushChanges(commitMessage string, open bool) error
PushChanges commits and pushes changes in the worktree to the remote branch
func (*GitWorktree) Remove ¶
func (g *GitWorktree) Remove() error
Remove removes the worktree but keeps the branch
func (*GitWorktree) Setup ¶
func (g *GitWorktree) Setup() error
Setup creates a new worktree for the session