git

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2014 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusUpToDate means the local repo matches origin
	StatusUpToDate = iota

	// StatusNeedToPull means the local repo needs to pull from the remote
	StatusNeedToPull

	// StatusNeedToPush means the local repo needs to be pushed to the remote
	StatusNeedToPush

	// StatusDiverged means the local repo has diverged from the remote
	StatusDiverged
)

Variables

View Source
var GitRemoteRegex = regexp.MustCompile(`^([^\t\n\f\r ]+)[\t\n\v\f\r ]+(git@github\.com:|(http[s]?|git):\/\/github\.com\/)([a-zA-Z0-9]{1}[a-zA-Z0-9-]*)\/([a-zA-Z0-9_.-]+)(\.git|[^\t\n\f\r ])+.*$`)

GitRemoteRegex is a regex for pulling account owner from the output of `git remote -v`

Functions

func AccountFromRemotes

func AccountFromRemotes(remotes string) string

AccountFromRemotes produces the (GitHub) account from the output of `git remote -v` - this ouput is nominally provided by the Remotes function but may be provided otherwise for testing purposes

func Branch

func Branch(top string) string

Branch determines the git branch in the repo located at `top`. Two attempts are made to determine branch. First:

git rev-parse -q --abbrev-ref HEAD

If the current working directory is not on a branch, the result will return "HEAD". In this case, branch will be estimated by parsing the output of the following:

git branch --contains $(git rev-parse -q HEAD)

func IsClean

func IsClean(top string) bool

IsClean returns true `git diff --shortstat` produces no output

func RemoteAccount

func RemoteAccount(top string) string

RemoteAccount returns the github account as determined by the output of `git remote -v`

func Remotes

func Remotes(top string) string

Remotes returns the output of `git remote -v

func Repo

func Repo(top string) string

Repo produces the repo name as determined by the basename of $PWD

func Sha

func Sha(top string) string

Sha produces the git branch at `top` as determined by `git rev-parse -q HEAD`

func Tag

func Tag(top string) string

Tag produces the git tag at `top` as determined by `git describe --always --dirty --tags`

func UpToDate

func UpToDate(top string) int

UpToDate returns the status of the repo as determined by the above constants

Types

This section is empty.

Jump to

Keyboard shortcuts

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