Documentation
¶
Overview ¶
Package local discovers a git repository already checked out on the local filesystem: the URL of one of its remotes, and the branch checked out.
This sits outside the git.Client interface on purpose. Discovery is local, read-only, and needs neither auth nor network, so both access backends would implement it identically; go-git can read a repository's config regardless of which backend is configured for remote operations.
Index ¶
Constants ¶
const DefaultRemote = "origin"
DefaultRemote is the remote Discover reads when none is requested.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NotARepositoryError ¶
NotARepositoryError indicates no git repository was found at or above the requested path. Callers use errors.As to tell this apart from failures reading a repository that does exist.
func (*NotARepositoryError) Error ¶
func (e *NotARepositoryError) Error() string
func (*NotARepositoryError) Unwrap ¶
func (e *NotARepositoryError) Unwrap() error
type RemoteNotFoundError ¶
RemoteNotFoundError indicates the repository was opened but has no remote by the requested name. Available lists the remotes it does have, so callers can say what the user could have asked for instead.
func (*RemoteNotFoundError) Error ¶
func (e *RemoteNotFoundError) Error() string
func (*RemoteNotFoundError) Unwrap ¶
func (e *RemoteNotFoundError) Unwrap() error
type Repository ¶
type Repository struct {
Root string // absolute path of the working tree root; "" for a bare repository
RemoteURL string // URL of the requested remote, exactly as git config records it
HeadRef string // short branch name; "" when HEAD is detached or unborn
HeadSHA string // commit HEAD points at; "" when HEAD is unborn
}
Repository describes a repository checked out on the local filesystem.
func Discover ¶
func Discover(path, remote string) (Repository, error)
Discover opens the repository containing path (walking up until a .git directory or file is found) and reports the URL of remote along with the branch currently checked out. An empty path means the process's working directory; an empty remote means DefaultRemote.