gitutil

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGitFatal is returned by Git for fatal application errors, such as
	// if Git cannot find the .git directory.
	ErrGitFatal = errors.New("git error")

	// ErrGitUsage is returned by Git for errors in command line usage..
	ErrGitUsage = errors.New("git invalid usage")
)
View Source
var (
	// ErrNotAGitDir is returned when the directory given to the function is
	// not within a Git repository.
	ErrNotAGitDir = errors.New("not a Git directory")
)

Functions

func GitRepoRoot

func GitRepoRoot(dir string) (string, error)

GitRepoRoot looks recursively upwards for the Git repository root directory using the file system from the OS.

func GitRepoRootFS

func GitRepoRootFS(dir string, statFS fs.StatFS) (string, error)

GitRepoRootFS looks recursively upwards for the Git repository root directory using a fs.StatFS.

func IsGitRepo

func IsGitRepo(dir string) (bool, error)

IsGitRepo checks recursively upwards if a directory is inside a Git repository using the file system from the OS.

func IsGitRepoFS

func IsGitRepoFS(dir string, statFS fs.StatFS) (bool, error)

IsGitRepoFS checks recursively upwards if a directory is inside a Git repository using a fs.StatFS.

func NewIgnorer

func NewIgnorer(currentDir, repoRoot string) (ignorer.Ignorer, error)

NewIgnorer creates a new ignorer that checks if a file should be ignored or not depending on the .gitignore files found inside the repository.

Types

type Remote

type Remote struct {
	FetchURL string
	PushURL  string
}

Remote is a Git remote, containing the fetch and pull URLs.

type Stats

type Stats struct {
	CurrentBranch      string
	CurrentBranchSafe  string
	LatestTag          string
	Tags               []string
	CommitHash         string
	CommitShortHash    string
	CommitSubject      string
	CommitComitterDate string
	CommitAuthorDate   string
	Revision           int
	Remotes            map[string]Remote
	EstimatedRepoGroup string
	EstimatedRepoName  string
}

Stats contains info about a Git repository.

func StatsFromExec

func StatsFromExec(dir string) (Stats, error)

StatsFromExec obtains Git repo stats by executing different Git commands.

func (Stats) ListVars

func (s Stats) ListVars() []varsub.Var

ListVars will return a slice of all variables that this varsub Source provides.

func (Stats) Lookup

func (s Stats) Lookup(name string) (varsub.Var, bool)

Lookup tries to get a value based on the correlated built-in variable name. This method implements the varsub.Source interface.

The string name -> field mapping is based on the documentation: https://iver-wharf.github.io/#/usage-wharfyml/variables/built-in-variables

func (Stats) String

func (s Stats) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL