Documentation ¶
Overview ¶
Package gitutil provides helpers for dealing with git repositories.
Index ¶
- func ApplyInsteadOf(remoteURL string) (url string, err error)
- func DefaultRef(url string) (ref plumbing.ReferenceName, err error)
- func DetectGitPath(path string) (string, error)
- func FindInsteadOfMatch(remoteURL string, urls map[string]*config.URL) *config.URL
- func FindLocalRepoPath() (path string, err error)
- func FindRef(url string, refname string) (ref plumbing.ReferenceName, err error)
- func GetRefs(url string) (refs memory.ReferenceStorage, err error)
- func LoadGitConfig() (conf *config.Config, err error)
- func LocalBranch() (ref plumbing.ReferenceName, err error)
- func RemoteDefaultBranch() (ref plumbing.ReferenceName, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyInsteadOf ¶
ApplyInsteadOf returns the remote URL with the instead of rules applied.
func DefaultRef ¶
func DefaultRef(url string) (ref plumbing.ReferenceName, err error)
DefaultRef returns a ref pointing at the default HEAD for the repository, since not all repositories will use "main", this will determine it for us.
func DetectGitPath ¶
DetectGitPath returns the repository root of the specified path, if there is one.
func FindInsteadOfMatch ¶
FindInsteadOfMatch returns the longest matching URL rule
This is borrowed directly from go-git: https://github.com/go-git/go-git/blob/master/config/url.go#L59
func FindLocalRepoPath ¶
FindLocalRepoPath returns the full path to the repository containing the current working directory. This is not really useful for anything except providing a shortcut to that path for tests, and maybe automation tools.
func FindRef ¶
func FindRef(url string, refname string) (ref plumbing.ReferenceName, err error)
FindRef returns a ref from the given refname, or falls back to the default branch for the repository.
func GetRefs ¶
func GetRefs(url string) (refs memory.ReferenceStorage, err error)
GetRefs returns a map of all the available refs
This is borrowed from: https://github.com/go-git/go-git/issues/249#issuecomment-772354474
func LoadGitConfig ¶
LoadGitConfig returns the system and global git configs merged together.
This is borrowed directly from go-git: https://github.com/go-git/go-git/blob/master/repository.go#L489
func LocalBranch ¶
func LocalBranch() (ref plumbing.ReferenceName, err error)
LocalBranch returns the current ref for this repository.
func RemoteDefaultBranch ¶
func RemoteDefaultBranch() (ref plumbing.ReferenceName, err error)
RemoteDefaultBranch returns the current ref for this repository.
Types ¶
This section is empty.