Documentation ¶
Overview ¶
Package git contains various commands that shell out to git
Index ¶
- Constants
- Variables
- func CloneWithoutFilters(flags CloneFlags, args []string) error
- func DefaultRemote() (string, error)
- func FormatGitDate(tm time.Time) string
- func GetTrackedFiles(pattern string) ([]string, error)
- func GitAndRootDirs() (string, string, error)
- func GitDir() (string, error)
- func IsVersionAtLeast(actualVersion, desiredVersion string) bool
- func LsRemote(remote, remoteRef string) (string, error)
- func ParseGitDate(str string) (time.Time, error)
- func RemoteBranchForLocalBranch(localBranch string) string
- func RemoteForBranch(localBranch string) string
- func RemoteForCurrentBranch() (string, error)
- func RemoteList() ([]string, error)
- func RemoteRefNameForCurrentBranch() (string, error)
- func RootDir() (string, error)
- func UpdateIndex(file string) error
- func ValidateRemote(remote string) error
- type CloneFlags
- type CommitSummary
- type Ref
- func CachedRemoteRefs(remoteName string) ([]*Ref, error)
- func CurrentRef() (*Ref, error)
- func CurrentRemoteRef() (*Ref, error)
- func GetAllWorkTreeHEADs(storageDir string) ([]*Ref, error)
- func LocalRefs() ([]*Ref, error)
- func RecentBranches(since time.Time, includeRemoteBranches bool, onlyRemote string) ([]*Ref, error)
- func RemoteRefs(remoteName string) ([]*Ref, error)
- func ResolveRef(ref string) (*Ref, error)
- func ResolveRefs(refnames []string) ([]*Ref, error)
- type RefType
Constants ¶
Variables ¶
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
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
FormatGitDate converts a Go date into a git command line format date
func GetTrackedFiles ¶ added in v1.2.0
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 IsVersionAtLeast ¶ added in v1.1.0
IsVersionAtLeast compares 2 version strings (ok to be prefixed with 'git version', ignores)
func ParseGitDate ¶ added in v0.6.0
Parse a Git date formatted in ISO 8601 format (%ci/%ai)
func RemoteBranchForLocalBranch ¶ added in v1.0.1
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
RemoteForBranch returns the remote name that a given local branch is tracking (blank if none)
func RemoteForCurrentBranch ¶ added in v1.0.1
RemoteForCurrentBranch returns the name of the remote that the current branch is tracking
func RemoteList ¶ added in v1.0.1
func RemoteRefNameForCurrentBranch ¶ added in v1.0.1
RemoteRefForCurrentBranch returns the full remote ref (remote/remotebranch) that the current branch is tracking
func UpdateIndex ¶ added in v0.5.2
func ValidateRemote ¶ added in v1.0.1
ValidateRemote checks that a named remote is valid for use Mainly to check user-supplied remotes & fail more nicely
Types ¶
type CloneFlags ¶ added in v1.2.1
type CloneFlags struct { // --template <template_directory> TemplateDirectory string // -l --local Local bool 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
A git reference (branch, tag etc)
func CachedRemoteRefs ¶ added in v1.2.0
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 CurrentRemoteRef ¶
func GetAllWorkTreeHEADs ¶ added in v1.1.0
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
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
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
RemoteRefs returns a list of branches & tags for a remote by actually accessing the remote vir git ls-remote