Documentation ¶
Overview ¶
Package gitinfo provides an interface to high-level git information for a git working copy. gitinfo attempts to use the locally installed "git" executable using https://github.com/denormal/go-gittools.
Index ¶
Constants ¶
const ( BRANCH = "branch" COMMIT = "commit" EDITOR = "editor" GIT = "git" MODIFIED = "modified" PATH = "path" ROOT = "root" USER_NAME = "user.name" USER_EMAIL = "user.email" )
Variables ¶
var ( MissingGitError = gittools.MissingGitError MissingWorkingCopyError = gittools.MissingWorkingCopyError UnknownCallerError = errors.New("unable to determine caller") )
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit interface { // String returns the full commit hash. String() string // Prefix returns the first n characters of the commit hash. Prefix(n int) string }
Commit represents a git commit hash.
type GitInfo ¶
type GitInfo interface { // Branch returns the current branch name for the working copy. If the // GitInfo instance was initialised for a path not within a working copy, // Branch will return the empty string. An error is returned if there is // a problem determining the branch name. Branch() (string, error) // Commit returns the most recent Commit details for the working // copy. If the GitInfo instance was initialised for a path not within a // working copy, Commit will return nil. An error is returned if there is // a problem determining the commit details. Commit() (Commit, error) // Config returns the git configuration details for the working copy. // see https://github.com/denormal/go-gitconfig for more details. Config() gitconfig.GitConfig // Editor returns the git editor configured for working copy. Editor() string // Modified returns true if the working copy has been modified, either // through locally made changes, or untracked files. Modified returns an // error if a problem is encountered determining the modified state. Modified() (bool, error) // Path returns the absolute path used to initialised this GitInfo. Path() string // Root returns the root directory of the working copy. If the GitInfo // instance was initialised for a path not within a working copy, Root // returns the empty string. Root() string // User returns details of the git user for this working copy. User() User // Deprecated: Version returns the version string for the installed git // executable, or an error if this cannot be determined. // // Version is deprecated and will be removed in a future release. Please // use Git() for extracting the git executable version. Version() (string, error) // Git returns the version string for the installed git executable, // or an error if this cannot be determined. Git() (string, error) // Map returns the git information as a map of strings. Map() map[string]string }
GitInfo represents basic information about a git working copy.
func Here ¶
Here returns the GitInfo instance referencing the caller's location. If the caller cannot be determined, Here returns the UnknownCallerError.
func New ¶
New returns the GitInfo instance for the current process working directory, or an error if the directory cannot be resolved, or the git executable cannot be found.
func NewWithPath ¶
NewWithPath returns the GitInfo instance for the given path, or an error if the path cannot be resolved or the git executable cannot be found. If path is "", NewWithPath examines the current process working directory.
type User ¶
type User interface { // Name returns the name of the current git user, or the empty string // if no name is configured. Name() string // Email returns the e-mail addrdd of the current git user, or the empty // string if no e-mail address is configured. Email() string // String() returns a string representation of the git user's name and // e-mail address, or the empty string if neither are defined. String() string }
User is the interface representing the git user.