Documentation
¶
Overview ¶
Package git runs local git commands for cloning repos, fetching PR merge refs, and checking out commits.
Index ¶
- func CheckoutFetchHead(repoPath string) (string, error)
- func CheckoutRef(repoPath, ref string) error
- func Clone(parentDir, cloneURL, targetPath string) error
- func EnsurePathIsRepo(repoPath, cloneURL string, force bool) error
- func FetchPRMergeRef(repoPath string, prNumber int) error
- func GetCurrentRef(repoPath string) (string, error)
- func IsRepoForRemote(repoPath, cloneURL string) bool
- func IsWorkingTreeDirty(repoPath string) (dirty bool, output string, err error)
- func ResetAndClean(repoPath string) error
- func Run(repoPath string, args ...string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckoutFetchHead ¶
func CheckoutRef ¶ added in v1.2.0
CheckoutRef checks out the given branch name or commit SHA.
func EnsurePathIsRepo ¶
EnsurePathIsRepo ensures the given path contains a git repository. If the directory doesn't exist or is empty, it clones from cloneURL. It verifies a .git directory exists. If force is true, uncommitted changes are discarded with git reset + clean; otherwise an error is returned.
func FetchPRMergeRef ¶
func GetCurrentRef ¶ added in v1.2.0
GetCurrentRef returns the current branch name, tag name, or commit SHA (in that order of preference).
func IsRepoForRemote ¶ added in v1.2.0
IsRepoForRemote returns true if the git repo at repoPath has a remote URL that refers to the same GitHub repository as cloneURL. It normalises both URLs to "host/owner/repo" before comparing so that SSH and HTTPS forms match.
func IsWorkingTreeDirty ¶
IsWorkingTreeDirty returns true if the repo has uncommitted changes, along with the porcelain output describing them.
func ResetAndClean ¶
ResetAndClean discards all uncommitted changes (tracked and untracked).
Types ¶
This section is empty.