Documentation
¶
Overview ¶
Package git provides Git operations and error definitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBranchNotFound = errors.New("branch not found") ErrWorktreeExists = errors.New("worktree already exists") ErrWorktreeNotFound = errors.New("worktree not found") ErrWorktreePathNotFound = errors.New("worktree path not found") ErrRepositoryNotClean = errors.New("repository is not clean") ErrRemoteAddFailed = errors.New("failed to add remote") ErrFetchFailed = errors.New("failed to fetch from remote") ErrBranchNotFoundOnRemote = errors.New("branch not found on remote") // 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") )
Git-specific error types.
Functions ¶
func SetupTestRepo ¶ added in v0.26.0
SetupTestRepo creates a temporary git repository for testing.
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) // 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, force bool) 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) // 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) // Add adds files to the Git staging area. Add(repoPath string, files ...string) error // CreateBranch creates a new branch from the current branch. CreateBranch(repoPath, branch string) error // Commit creates a new commit with the specified message. Commit(repoPath, message string) error // GetBranchRemote gets the remote name for a branch (e.g., "origin", "justenstall"). GetBranchRemote(repoPath, branch string) (string, error) // SetUpstreamBranch sets the upstream branch for the current branch. SetUpstreamBranch(repoPath, remote, branch string) error }
Git interface provides Git command execution capabilities.
Source Files
¶
- add.go
- add_remote.go
- branch_exists.go
- branch_exists_on_remote.go
- check_reference_conflict.go
- checkout_branch.go
- clone.go
- commit.go
- config_get.go
- create_branch.go
- create_branch_from.go
- create_worktree.go
- create_worktree_with_no_checkout.go
- errors.go
- fetch_remote.go
- get_branch_remote.go
- get_current_branch.go
- get_default_branch.go
- get_remote_url.go
- get_repository_name.go
- get_worktree_path.go
- git.go
- is_clean.go
- remote_exists.go
- remove_worktree.go
- set_upstream_branch.go
- status.go
- test_utils.go
- types.go
- utils.go
- worktree_exists.go
Click to show internal directories.
Click to hide internal directories.