Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandIsInstalled ¶
func CommandIsInstalled() bool
func CommitID ¶
CommitID return the commit id of HEAD by running git rev-parse in the passed directory
func IsGitDir ¶
IsGitDir checks if the passed directory is in a git repository. It returns true if: - .git/ exists or - the "git" command is in $PATH and "git rev-parse --git-dir" returns exit code 0 It returns false if:
- .git/ does not exist and the "git" command is not in $PATH or "git rev-parse --git-dir" exits with code 128
func LsFiles ¶
LsFiles runs git ls-files in dir, passes args as argument and returns a list of paths. All pathspecs are treated literally, globs are not resolved.
func WorktreeIsDirty ¶
WorktreeIsDirty returns true if the repository contains modified files, untracked files are considered, files in .gitignore are ignored
Types ¶
type RepositoryState ¶
type RepositoryState struct {
// contains filtered or unexported fields
}
RepositoryState lazyLoads and caches the commitID and worktree state of a Git repository.
func NewRepositoryState ¶
func NewRepositoryState(repositoryPath string) *RepositoryState
NewRepositoryState initializes a RepositoryState for the given git repository.
func (*RepositoryState) CommitID ¶
func (g *RepositoryState) CommitID() (string, error)
CommitID calls git.CommitID() for the repository. After the first successful call the commit ID is stored and the stored value is returned on successive calls.
func (*RepositoryState) WorktreeIsDirty ¶
func (g *RepositoryState) WorktreeIsDirty() (bool, error)
WorktreeIsDirty calls git.WorktreeIsDirty. After the first successful call the result is stored and the stored value is returned on successive calls.