Documentation
¶
Overview ¶
Package git provides functions for interacting with git repositories by shelling out to the git CLI.
Index ¶
- func Checkout(repoPath, branch string) error
- func CommitAuthors(repoPath, branch, base string) ([]string, error)
- func CommitDate(repoPath, branch string) (time.Time, error)
- func CommitSubject(repoPath, ref string) (string, error)
- func CommitsAheadBehind(repoPath, branch, base string) (ahead int, behind int, err error)
- func ConfigValue(repoPath, key string) (string, error)
- func CreateTag(repoPath, tagName, ref string) error
- func CurrentBranch(repoPath string) (string, error)
- func DefaultBranch(repoPath string) (string, error)
- func DeleteLocalBranch(repoPath, branch string, force bool) error
- func DeleteRemoteBranch(repoPath, remote, branch string) error
- func Fetch(repoPath, remote string) error
- func HasRemote(repoPath, remote string) bool
- func HasRemoteBranch(repoPath, remote, branch string) (bool, error)
- func HasUpstream(repoPath, branch string) bool
- func IsClean(repoPath string) (bool, error)
- func IsMerged(repoPath, branch, base string) (bool, error)
- func IsRepo(path string) bool
- func ListBranches(repoPath string) ([]string, error)
- func MergeAbort(repoPath string) error
- func MergeBase(repoPath string, ref1, ref2 string) (string, error)
- func MergeTree(repoPath string, base, local, remote string) (string, bool, error)
- func MergedBranches(repoPath, base string) ([]string, error)
- func Pull(repoPath string, strategy string) error
- func RebaseAbort(repoPath string) error
- func RemoteURL(repoPath, remote string) (string, error)
- func StashPop(repoPath string) error
- func StashPush(repoPath string, message string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitAuthors ¶ added in v0.3.0
CommitAuthors returns the set of unique author emails for all commits on branch that are not reachable from base. This identifies who contributed to the branch since it diverged.
func CommitDate ¶
CommitDate returns the author date of the latest commit on the given branch.
func CommitSubject ¶ added in v0.2.2
CommitSubject returns the subject line of the latest commit on the given ref.
func CommitsAheadBehind ¶ added in v0.2.2
CommitsAheadBehind returns the number of commits that branch is ahead of and behind base. This uses rev-list to count commits reachable from one ref but not the other.
func ConfigValue ¶ added in v0.3.0
ConfigValue returns the value of a git config key in the given repo.
func CurrentBranch ¶
CurrentBranch returns the name of the currently checked-out branch.
func DefaultBranch ¶
DefaultBranch returns the default branch name (main or master) by checking what the origin HEAD points to, falling back to a local heuristic.
func DeleteLocalBranch ¶
DeleteLocalBranch deletes a local branch. If force is true, uses -D instead of -d.
func DeleteRemoteBranch ¶
DeleteRemoteBranch deletes a branch on the given remote.
func HasRemoteBranch ¶ added in v0.2.2
HasRemoteBranch returns true if the given branch exists on the specified remote.
func HasUpstream ¶ added in v0.3.0
HasUpstream returns true if the given branch has a remote tracking branch configured.
func ListBranches ¶
ListBranches returns all local branch names.
func MergeAbort ¶ added in v0.2.0
MergeAbort aborts an in-progress merge, restoring the branch to its pre-merge state.
func MergeBase ¶ added in v0.2.0
MergeBase returns the best common ancestor commit between two refs.
func MergeTree ¶ added in v0.2.0
MergeTree performs a three-way merge-tree between base, local, and remote tree-ish references. It returns the merge output, whether conflicts were detected, and any error. This is a read-only operation that does not modify the working tree.
func MergedBranches ¶
MergedBranches returns local branches that have been merged into the given base branch.
func Pull ¶ added in v0.2.0
Pull pulls from the default remote using the given strategy. Valid strategies: "rebase", "merge", "ff-only".
func RebaseAbort ¶ added in v0.2.0
RebaseAbort aborts an in-progress rebase, restoring the branch to its pre-rebase state.
Types ¶
This section is empty.