Documentation
¶
Overview ¶
Package git provides Git operations and error definitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrGitCommandFailed = errors.New("git command failed") ErrBranchNotFound = errors.New("branch not found") ErrWorktreeExists = errors.New("worktree already exists") ErrWorktreeNotFound = errors.New("worktree not found") ErrWorktreeDeletionFailed = errors.New("failed to delete worktree") ErrWorktreePathNotFound = errors.New("worktree path not found") ErrRepositoryNotClean = errors.New("repository is not clean") ErrRemoteOriginNotFound = errors.New("remote origin not found") ErrRemoteNotFound = errors.New("remote not found") ErrRemoteAddFailed = errors.New("failed to add remote") ErrFetchFailed = errors.New("failed to fetch from remote") ErrBranchNotFoundOnRemote = errors.New("branch not found on remote") ErrReferenceConflict = errors.New("reference conflict: cannot create branch due to existing reference") // Specific reference conflict error types for testing. ErrBranchParentExists = errors.New("cannot create branch: reference already exists") ErrTagParentExists = errors.New("cannot create branch: tag already exists") // SSH errors. ErrSSHAuthentication = errors.New("ssh authentication failed") )
Git-specific error types.
Functions ¶
This section is empty.
Types ¶
type BranchExistsOnRemoteParams ¶
BranchExistsOnRemoteParams contains parameters for BranchExistsOnRemote.
type CloneParams ¶
CloneParams contains parameters for Clone.
type CreateBranchFromParams ¶ added in v0.15.0
CreateBranchFromParams contains parameters for CreateBranchFrom.
type Git ¶
type Git interface {
// Status executes `git status` in specified directory.
Status(workDir string) (string, error)
// ConfigGet executes `git config --get <key>` in specified directory.
ConfigGet(workDir, key string) (string, error)
// CreateWorktree creates a new worktree for the specified branch.
CreateWorktree(repoPath, worktreePath, branch string) error
// CreateWorktreeWithNoCheckout creates a new worktree without checking out files.
CreateWorktreeWithNoCheckout(repoPath, worktreePath, branch string) error
// CheckoutBranch checks out a branch in the specified worktree.
CheckoutBranch(worktreePath, branch string) error
// GetCurrentBranch gets the current branch name.
GetCurrentBranch(repoPath string) (string, error)
// GetRepositoryName gets the repository name from remote origin URL with fallback to local path.
GetRepositoryName(repoPath string) (string, error)
// IsClean checks if the repository is in a clean state (placeholder for future validation).
IsClean(repoPath string) (bool, error)
// BranchExists checks if a branch exists locally or remotely.
BranchExists(repoPath, branch string) (bool, error)
// CreateBranch creates a new branch from the current branch.
CreateBranch(repoPath, branch string) error
// CreateBranchFrom creates a new branch from a specific branch.
CreateBranchFrom(params CreateBranchFromParams) error
// CheckReferenceConflict checks if creating a branch would conflict with existing references.
CheckReferenceConflict(repoPath, branch string) error
// WorktreeExists checks if a worktree exists for the specified branch.
WorktreeExists(repoPath, branch string) (bool, error)
// RemoveWorktree removes a worktree from Git's tracking.
RemoveWorktree(repoPath, worktreePath string) error
// GetWorktreePath gets the path of a worktree for a branch.
GetWorktreePath(repoPath, branch string) (string, error)
// AddRemote adds a new remote to the repository.
AddRemote(repoPath, remoteName, remoteURL string) error
// FetchRemote fetches from a specific remote.
FetchRemote(repoPath, remoteName string) error
// BranchExistsOnRemote checks if a branch exists on a specific remote.
BranchExistsOnRemote(params BranchExistsOnRemoteParams) (bool, error)
// GetRemoteURL gets the URL of a remote.
GetRemoteURL(repoPath, remoteName string) (string, error)
// RemoteExists checks if a remote exists.
RemoteExists(repoPath, remoteName string) (bool, error)
// GetBranchRemote gets the remote name for a branch (e.g., "origin", "justenstall").
GetBranchRemote(repoPath, branch string) (string, error)
// Add adds files to the Git staging area.
Add(repoPath string, files ...string) error
// Commit creates a new commit with the specified message.
Commit(repoPath, message string) error
// Clone clones a repository to the specified path.
Clone(params CloneParams) error
// GetDefaultBranch gets the default branch name from a remote repository.
GetDefaultBranch(remoteURL string) (string, error)
}
Git interface provides Git command execution capabilities.
Click to show internal directories.
Click to hide internal directories.