Documentation
¶
Index ¶
- Variables
- type ExecGit
- func (g *ExecGit) AddAll(dir string) error
- func (g *ExecGit) Checkout(dir, branch string, create bool) error
- func (g *ExecGit) Clone(tokenURL, dir, branch string, depth int) error
- func (g *ExecGit) Commit(dir, message, authorName, authorEmail string) error
- func (g *ExecGit) Fetch(dir, tokenURL, branch string) error
- func (g *ExecGit) IsClean(dir string) (bool, error)
- func (g *ExecGit) Pull(dir, tokenURL, branch string) error
- func (g *ExecGit) Push(dir, tokenURL, branch string) error
- func (g *ExecGit) WorktreeAdd(repoDir, worktreeDir, branch string, create bool) error
- func (g *ExecGit) WorktreePrune(repoDir string) error
- func (g *ExecGit) WorktreeRemove(repoDir, worktreeDir string) error
- type Git
- type GitError
Constants ¶
This section is empty.
Variables ¶
var ( ErrBranchAlreadyExists = errors.New("git: branch already exists") ErrAlreadyUpToDate = errors.New("git: already up to date") ErrReferenceNotFound = errors.New("git: reference not found") ErrRemoteRefNotFound = errors.New("git: couldn't find remote ref") ErrWorktreeAlreadyExists = errors.New("git: worktree already checked out") )
Functions ¶
This section is empty.
Types ¶
type ExecGit ¶
type ExecGit struct {
// contains filtered or unexported fields
}
ExecGit runs git commands via the system git binary.
func (*ExecGit) Checkout ¶
Checkout switches to branch. When create=true it tries -b first, then falls back to a plain checkout if the branch already exists.
func (*ExecGit) Commit ¶
Commit creates a commit with the given message and author/committer identity. -c user.name/email sets the committer; --author sets the author explicitly.
func (*ExecGit) Fetch ¶
Fetch fetches branch from the given URL. ErrRemoteRefNotFound, ErrAlreadyUpToDate, "refusing to fetch into current branch", and "shallow update not allowed" are swallowed.
func (*ExecGit) Pull ¶
Pull hard-resets HEAD then fast-forward pulls from the given URL. ErrAlreadyUpToDate is swallowed; all other errors (including ErrReferenceNotFound when the remote branch does not exist) are surfaced to the caller.
func (*ExecGit) Push ¶
Push pushes the current HEAD to branch on the remote using an unambiguous refs/heads/ refspec. ErrAlreadyUpToDate is swallowed.
func (*ExecGit) WorktreeAdd ¶ added in v2.1.0
WorktreeAdd creates a git worktree at worktreeDir for the given branch. When create=true, a new branch is created (-b). If the worktree already exists (stale from an interrupted run), it is removed and retried.
func (*ExecGit) WorktreePrune ¶ added in v2.1.0
WorktreePrune removes stale worktree metadata from the repo.
func (*ExecGit) WorktreeRemove ¶ added in v2.1.0
WorktreeRemove forcefully removes a git worktree.
type Git ¶
type Git interface {
Clone(tokenURL, dir, branch string, depth int) error
Checkout(dir, branch string, create bool) error
Fetch(dir, tokenURL, branch string) error
Pull(dir, tokenURL, branch string) error
Push(dir, tokenURL, branch string) error
IsClean(dir string) (bool, error)
AddAll(dir string) error
Commit(dir, message, authorName, authorEmail string) error
WorktreeAdd(repoDir, worktreeDir, branch string, create bool) error
WorktreeRemove(repoDir, worktreeDir string) error
WorktreePrune(repoDir string) error
}