Documentation
¶
Index ¶
- func GetCommitsDivergenceFromMain(repoPath, currentBranch string) (ahead int, behind int)
- func GetCommitsDivergenceFromRemoteMain(repoPath, currentBranch string) (ahead int, behind int)
- func GetGitRoot(dir string) (string, error)
- func GetHeadCommit(dir string) (string, error)
- func GetRepoInfo(dir string) (repo string, branch string, err error)
- func GetSuperprojectRoot(dir string) (string, error)
- func IsGitRepo(dir string) bool
- func ResolveRef(dir, ref string) (string, error)
- type BranchChangeHandler
- type CLIRepository
- func (r *CLIRepository) GetEnvironmentVars(ctx context.Context, workDir string) (*EnvironmentVars, error)
- func (r *CLIRepository) GetGitRoot(ctx context.Context, dir string) (string, error)
- func (r *CLIRepository) GetRepoInfo(ctx context.Context, dir string) (repo string, branch string, err error)
- func (r *CLIRepository) IsGitRepo(ctx context.Context, dir string) bool
- type EnvironmentVars
- type ExtendedGitStatus
- type HookManager
- type HookProvider
- type RepositoryProvider
- type StatusInfo
- type WorktreeInfo
- type WorktreeManager
- func (m *WorktreeManager) CreateWorktree(ctx context.Context, basePath, worktreePath, branch string, createBranch bool) error
- func (m *WorktreeManager) GetCurrentWorktree(ctx context.Context, path string) (*WorktreeInfo, error)
- func (m *WorktreeManager) GetOrPrepareWorktree(ctx context.Context, basePath, worktreeName, branchName string) (string, bool, error)
- func (m *WorktreeManager) GetWorktreeRoot(ctx context.Context, path string) (string, error)
- func (m *WorktreeManager) ListWorktrees(ctx context.Context, repoPath string) ([]WorktreeInfo, error)
- func (m *WorktreeManager) RemoveWorktree(ctx context.Context, basePath, worktreePath string) error
- type WorktreeProvider
- type WorktreeWithStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCommitsDivergenceFromMain ¶
GetCommitsDivergenceFromMain returns the number of commits a branch is ahead of and behind the local main/master branch.
func GetCommitsDivergenceFromRemoteMain ¶
GetCommitsDivergenceFromRemoteMain returns the number of commits the local main/master branch is ahead of and behind origin/main or origin/master.
func GetGitRoot ¶
GetGitRoot returns the root directory of the git repository
func GetHeadCommit ¶
GetHeadCommit returns the current HEAD commit hash for a repository.
func GetRepoInfo ¶
GetRepoInfo returns the repository name and current branch
func GetSuperprojectRoot ¶
GetSuperprojectRoot returns the root directory of the superproject if in a submodule
func ResolveRef ¶
ResolveRef resolves a git ref (branch name, tag, or commit) to its full commit hash. Returns empty string and error if resolution fails.
Types ¶
type BranchChangeHandler ¶
type BranchChangeHandler struct{}
BranchChangeHandler handles branch changes
func NewBranchChangeHandler ¶
func NewBranchChangeHandler() *BranchChangeHandler
NewBranchChangeHandler creates a new branch change handler
func (*BranchChangeHandler) HandleBranchChange ¶
func (h *BranchChangeHandler) HandleBranchChange(workDir, fromBranch, toBranch string) error
HandleBranchChange responds to a branch change
type CLIRepository ¶
type CLIRepository struct {
// contains filtered or unexported fields
}
CLIRepository implements RepositoryProvider using git CLI
func NewCLIRepository ¶
func NewCLIRepository() *CLIRepository
NewCLIRepository creates a new CLI repository provider
func (*CLIRepository) GetEnvironmentVars ¶
func (r *CLIRepository) GetEnvironmentVars(ctx context.Context, workDir string) (*EnvironmentVars, error)
GetEnvironmentVars returns git-based environment variables
func (*CLIRepository) GetGitRoot ¶
GetGitRoot returns the root directory of the git repository
func (*CLIRepository) GetRepoInfo ¶
func (r *CLIRepository) GetRepoInfo(ctx context.Context, dir string) (repo string, branch string, err error)
GetRepoInfo returns repository and branch information
type EnvironmentVars ¶
type EnvironmentVars struct {
Repo string
Branch string
Commit string
CommitShort string
Author string
AuthorEmail string
WorktreePath string
IsDirty bool
}
EnvironmentVars contains git-based environment variables
func GetEnvironmentVars ¶
func GetEnvironmentVars(workDir string) (*EnvironmentVars, error)
GetEnvironmentVars returns git-based environment variables
func (*EnvironmentVars) SetEnvironment ¶
func (v *EnvironmentVars) SetEnvironment()
SetEnvironment sets git-based environment variables
func (*EnvironmentVars) ToMap ¶
func (v *EnvironmentVars) ToMap() map[string]string
ToMap converts environment vars to a map
type ExtendedGitStatus ¶
type ExtendedGitStatus struct {
*StatusInfo
LinesAdded int `json:"lines_added"`
LinesDeleted int `json:"lines_deleted"`
}
ExtendedGitStatus holds git status including line changes.
func GetExtendedStatus ¶
func GetExtendedStatus(path string) (*ExtendedGitStatus, error)
GetExtendedStatus fetches detailed git status including line changes.
type HookManager ¶
type HookManager struct {
// contains filtered or unexported fields
}
HookManager manages git hooks for Grove
func NewHookManager ¶
func NewHookManager(groveBinary string) *HookManager
NewHookManager creates a new hook manager
func (*HookManager) InstallHooks ¶
func (m *HookManager) InstallHooks(ctx context.Context, repoPath string) error
InstallHooks installs Grove git hooks
func (*HookManager) UninstallHooks ¶
func (m *HookManager) UninstallHooks(ctx context.Context, repoPath string) error
UninstallHooks removes Grove git hooks
type HookProvider ¶
type HookProvider interface {
// Hook management
InstallHooks(ctx context.Context, repoPath string) error
UninstallHooks(ctx context.Context, repoPath string) error
}
HookProvider defines the interface for git hook operations
type RepositoryProvider ¶
type RepositoryProvider interface {
// Repository information
GetRepoInfo(ctx context.Context, dir string) (repo string, branch string, err error)
IsGitRepo(ctx context.Context, dir string) bool
GetGitRoot(ctx context.Context, dir string) (string, error)
GetEnvironmentVars(ctx context.Context, workDir string) (*EnvironmentVars, error)
}
RepositoryProvider defines the interface for general git repository operations
type StatusInfo ¶
type StatusInfo struct {
// Branch is the current branch name
Branch string `json:"branch"`
// AheadCount is the number of commits ahead of the upstream branch
AheadCount int `json:"ahead_count"`
// BehindCount is the number of commits behind the upstream branch
BehindCount int `json:"behind_count"`
// ModifiedCount is the number of modified files
ModifiedCount int `json:"modified_count"`
// UntrackedCount is the number of untracked files
UntrackedCount int `json:"untracked_count"`
// StagedCount is the number of staged files
StagedCount int `json:"staged_count"`
// IsDirty indicates if there are any uncommitted changes
IsDirty bool `json:"is_dirty"`
// HasUpstream indicates if the branch has an upstream tracking branch
HasUpstream bool `json:"has_upstream"`
// AheadMainCount is the number of commits ahead of the local main/master branch
AheadMainCount int `json:"ahead_main_count"`
// BehindMainCount is the number of commits behind the local main/master branch
BehindMainCount int `json:"behind_main_count"`
}
StatusInfo contains detailed git status information for a repository
func GetStatus ¶
func GetStatus(path string) (*StatusInfo, error)
GetStatus returns detailed git status information for the repository at the given path
type WorktreeInfo ¶
WorktreeInfo contains information about a git worktree
type WorktreeManager ¶
type WorktreeManager struct {
// contains filtered or unexported fields
}
WorktreeManager manages git worktrees
func NewWorktreeManager ¶
func NewWorktreeManager() *WorktreeManager
NewWorktreeManager creates a new worktree manager
func (*WorktreeManager) CreateWorktree ¶
func (m *WorktreeManager) CreateWorktree(ctx context.Context, basePath, worktreePath, branch string, createBranch bool) error
CreateWorktree creates a new worktree
func (*WorktreeManager) GetCurrentWorktree ¶
func (m *WorktreeManager) GetCurrentWorktree(ctx context.Context, path string) (*WorktreeInfo, error)
GetCurrentWorktree returns info about the current worktree
func (*WorktreeManager) GetOrPrepareWorktree ¶
func (m *WorktreeManager) GetOrPrepareWorktree(ctx context.Context, basePath, worktreeName, branchName string) (string, bool, error)
GetOrPrepareWorktree gets an existing worktree or creates a new one This method is used by orchestration executors to ensure a consistent worktree setup Returns the worktree path, a boolean indicating if it was newly created, and an error
func (*WorktreeManager) GetWorktreeRoot ¶
GetWorktreeRoot returns the main worktree root
func (*WorktreeManager) ListWorktrees ¶
func (m *WorktreeManager) ListWorktrees(ctx context.Context, repoPath string) ([]WorktreeInfo, error)
ListWorktrees returns all worktrees for the current repository
func (*WorktreeManager) RemoveWorktree ¶
func (m *WorktreeManager) RemoveWorktree(ctx context.Context, basePath, worktreePath string) error
RemoveWorktree removes a worktree
type WorktreeProvider ¶
type WorktreeProvider interface {
// Worktree operations
ListWorktrees(ctx context.Context, repoPath string) ([]WorktreeInfo, error)
GetCurrentWorktree(ctx context.Context, path string) (*WorktreeInfo, error)
CreateWorktree(ctx context.Context, basePath, worktreePath, branch string, createBranch bool) error
RemoveWorktree(ctx context.Context, basePath, worktreePath string) error
GetWorktreeRoot(ctx context.Context, path string) (string, error)
}
WorktreeProvider defines the interface for git worktree operations
type WorktreeWithStatus ¶
type WorktreeWithStatus struct {
WorktreeInfo
Status *StatusInfo
}
WorktreeWithStatus contains worktree info plus its git status
func ListWorktreesWithStatus ¶
func ListWorktreesWithStatus(repoPath string) ([]WorktreeWithStatus, error)
ListWorktreesWithStatus returns worktrees with their git status