git

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package git contains various commands that shell out to git NOTE: Subject to change, do not rely on this package from outside git-lfs source

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 CloneWithoutFilters added in v1.2.0

func CloneWithoutFilters(flags CloneFlags, args []string) error

CloneWithoutFilters clones a git repo but without the smudge filter enabled so that files in the working copy will be pointers and not real LFS data

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 GetTrackedFiles added in v1.2.0

func GetTrackedFiles(pattern string) ([]string, error)

GetTrackedFiles returns a list of files which are tracked in Git which match the pattern specified (standard wildcard form) Both pattern and the results are relative to the current working directory, not the root of the repository

func GitAndRootDirs added in v1.1.1

func GitAndRootDirs() (string, string, error)

func GitDir added in v1.0.1

func GitDir() (string, error)

func IsVersionAtLeast added in v1.1.0

func IsVersionAtLeast(actualVersion, desiredVersion string) bool

IsVersionAtLeast compares 2 version strings (ok to be prefixed with 'git version', ignores)

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 (refs/remotes/{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

func ValidateRemoteURL added in v1.4.0

func ValidateRemoteURL(remote string) error

ValidateRemoteURL checks that a string is a valid Git remote URL

Types

type CloneFlags added in v1.2.1

type CloneFlags struct {
	// --template <template_directory>
	TemplateDirectory string
	// -l --local
	Local bool
	// -s --shared
	Shared bool
	// --no-hardlinks
	NoHardlinks bool
	// -q --quiet
	Quiet bool
	// -n --no-checkout
	NoCheckout bool
	// --progress
	Progress bool
	// --bare
	Bare bool
	// --mirror
	Mirror bool
	// -o <name> --origin <name>
	Origin string
	// -b <name> --branch <name>
	Branch string
	// -u <upload-pack> --upload-pack <pack>
	Upload string
	// --reference <repository>
	Reference string
	// --dissociate
	Dissociate bool
	// --separate-git-dir <git dir>
	SeparateGit string
	// --depth <depth>
	Depth string
	// --recursive
	Recursive bool
	// --recurse-submodules
	RecurseSubmodules bool
	// -c <value> --config <value>
	Config string
	// --single-branch
	SingleBranch bool
	// --no-single-branch
	NoSingleBranch bool
	// --verbose
	Verbose bool
	// --ipv4
	Ipv4 bool
	// --ipv6
	Ipv6 bool
}

For compatibility with git clone we must mirror all flags in CloneWithoutFilters

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 CachedRemoteRefs added in v1.2.0

func CachedRemoteRefs(remoteName string) ([]*Ref, error)

CachedRemoteRefs returns the list of branches & tags for a remote which are currently cached locally. No remote request is made to verify them.

func CurrentRef

func CurrentRef() (*Ref, error)

func CurrentRemoteRef

func CurrentRemoteRef() (*Ref, error)

func GetAllWorkTreeHEADs added in v1.1.0

func GetAllWorkTreeHEADs(storageDir string) ([]*Ref, error)

GetAllWorkTreeHEADs returns the refs that all worktrees are using as HEADs This returns all worktrees plus the master working copy, and works even if working dir is actually in a worktree right now Pass in the git storage dir (parent of 'objects') to work from

func LocalRefs added in v1.2.0

func LocalRefs() ([]*Ref, error)

Refs returns all of the local and remote branches and tags for the current repository. Other refs (HEAD, refs/stash, git notes) are ignored.

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 RemoteRefs added in v1.2.0

func RemoteRefs(remoteName string) ([]*Ref, error)

RemoteRefs returns a list of branches & tags for a remote by actually accessing the remote vir git ls-remote

func ResolveRef added in v0.5.2

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

func ResolveRefs added in v1.2.0

func ResolveRefs(refnames []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