git

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package git contains various commands that shell out to git

Package git contains various commands that shell out to git

Index

Constants

View Source
const (
	RefTypeLocalBranch  = RefType(iota)
	RefTypeRemoteBranch = RefType(iota)
	RefTypeLocalTag     = RefType(iota)
	RefTypeRemoteTag    = RefType(iota)
	RefTypeHEAD         = RefType(iota) // current checkout
	RefTypeOther        = RefType(iota) // stash or unknown
)

Variables

View Source
var Config = &gitConfig{}

Functions

func CurrentBranch

func CurrentBranch() (string, error)

func DefaultRemote added in v1.0.1

func DefaultRemote() (string, error)

DefaultRemote returns the default remote based on: 1. The currently tracked remote branch, if present 2. "origin", if defined 3. Any other SINGLE remote defined in .git/config Returns an error if all of these fail, i.e. no tracked remote branch, no "origin", and either no remotes defined or 2+ non-"origin" remotes

func FormatGitDate added in v0.6.0

func FormatGitDate(tm time.Time) string

FormatGitDate converts a Go date into a git command line format date

func GitDir added in v1.0.1

func GitDir() (string, error)

func LsRemote

func LsRemote(remote, remoteRef string) (string, error)

func ParseGitDate added in v0.6.0

func ParseGitDate(str string) (time.Time, error)

Parse a Git date formatted in ISO 8601 format (%ci/%ai)

func RemoteBranchForLocalBranch added in v1.0.1

func RemoteBranchForLocalBranch(localBranch string) string

RemoteBranchForLocalBranch returns the name (only) of the remote branch that the local branch is tracking If no specific branch is configured, returns local branch name

func RemoteForBranch added in v1.0.1

func RemoteForBranch(localBranch string) string

RemoteForBranch returns the remote name that a given local branch is tracking (blank if none)

func RemoteForCurrentBranch added in v1.0.1

func RemoteForCurrentBranch() (string, error)

RemoteForCurrentBranch returns the name of the remote that the current branch is tracking

func RemoteList added in v1.0.1

func RemoteList() ([]string, error)

func RemoteRefNameForCurrentBranch added in v1.0.1

func RemoteRefNameForCurrentBranch() (string, error)

RemoteRefForCurrentBranch returns the full remote ref (remote/remotebranch) that the current branch is tracking

func RootDir added in v1.0.1

func RootDir() (string, error)

func UpdateIndex added in v0.5.2

func UpdateIndex(file string) error

func ValidateRemote added in v1.0.1

func ValidateRemote(remote string) error

ValidateRemote checks that a named remote is valid for use Mainly to check user-supplied remotes & fail more nicely

Types

type CommitSummary added in v0.6.0

type CommitSummary struct {
	Sha            string
	ShortSha       string
	Parents        []string
	CommitDate     time.Time
	AuthorDate     time.Time
	AuthorName     string
	AuthorEmail    string
	CommitterName  string
	CommitterEmail string
	Subject        string
}

Some top level information about a commit (only first line of message)

func GetCommitSummary added in v0.6.0

func GetCommitSummary(commit string) (*CommitSummary, error)

Get summary information about a commit

type Ref added in v0.6.0

type Ref struct {
	Name string
	Type RefType
	Sha  string
}

A git reference (branch, tag etc)

func CurrentRef

func CurrentRef() (*Ref, error)

func CurrentRemoteRef

func CurrentRemoteRef() (*Ref, error)

func RecentBranches added in v0.6.0

func RecentBranches(since time.Time, includeRemoteBranches bool, onlyRemote string) ([]*Ref, error)

RecentBranches returns branches with commit dates on or after the given date/time Return full Ref type for easier detection of duplicate SHAs etc since: refs with commits on or after this date will be included includeRemoteBranches: true to include refs on remote branches onlyRemote: set to non-blank to only include remote branches on a single remote

func ResolveRef added in v0.5.2

func ResolveRef(ref string) (*Ref, error)

type RefType added in v0.6.0

type RefType int

func ParseRefToTypeAndName added in v0.6.0

func ParseRefToTypeAndName(fullref string) (t RefType, name string)

Get the type & name of a git reference

Jump to

Keyboard shortcuts

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