git

package
v2.11.0-pre0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotOnAnyBranch = errors.New("git: not on any branch")

ErrNotOnAnyBranch indicates that the user is in detached HEAD state

Functions

func AddNamedRemote added in v2.11.0

func AddNamedRemote(url, name, dir string, branches []string) error

func CheckoutBranch

func CheckoutBranch(branch string) error

func CheckoutNewBranch added in v2.6.0

func CheckoutNewBranch(remoteName, branch string) error

func CommitBody

func CommitBody(sha string) (string, error)

func Config

func Config(name string) (string, error)

func CurrentBranch

func CurrentBranch() (string, error)

CurrentBranch reads the checked-out branch for the git repository

func DeleteLocalBranch

func DeleteLocalBranch(branch string) error

func GetDirFromPath added in v2.3.0

func GetDirFromPath(p string) (string, error)

ToplevelDirFromPath returns the top-level given path of the current repository

func GitCommand

func GitCommand(args ...string) (*exec.Cmd, error)

func HasLocalBranch

func HasLocalBranch(branch string) bool

func IsURL

func IsURL(u string) bool

func ParseURL

func ParseURL(rawURL string) (u *url.URL, err error)

ParseURL normalizes git remote urls

func PathFromRepoRoot added in v2.2.0

func PathFromRepoRoot() string

func Pull added in v2.3.0

func Pull(remote, branch string) error

pull changes from remote branch without version history

func Push

func Push(remote string, ref string, cmdOut, cmdErr io.Writer) error

Push publishes a git ref to a remote and sets up upstream configuration

func RunClone

func RunClone(cloneURL string, args []string) (target string, err error)

func SetRemoteResolution

func SetRemoteResolution(name, resolution string) error

func ToplevelDir

func ToplevelDir() (string, error)

ToplevelDir returns the top-level directory path of the current repository

func UncommittedChangeCount

func UncommittedChangeCount() (int, error)

func UpdateRemoteURL added in v2.3.0

func UpdateRemoteURL(name, u string) error

Types

type BranchConfig

type BranchConfig struct {
	RemoteName string
	RemoteURL  *url.URL
	MergeRef   string
}

func ReadBranchConfig

func ReadBranchConfig(branch string) (cfg BranchConfig)

ReadBranchConfig parses the `branch.BRANCH.(remote|merge)` part of git config

type Commit

type Commit struct {
	Sha   string
	Title string
}

func Commits

func Commits(baseRef, headRef string) ([]*Commit, error)

func LastCommit

func LastCommit() (*Commit, error)

type NotInstalled

type NotInstalled struct {
	// contains filtered or unexported fields
}

func (*NotInstalled) Error

func (e *NotInstalled) Error() string

type Ref

type Ref struct {
	Hash string
	Name string
}

Ref represents a git commit reference

func ShowRefs

func ShowRefs(ref ...string) ([]Ref, error)

ShowRefs resolves fully-qualified refs to commit hashes

type Remote

type Remote struct {
	Name     string
	Resolved string
	FetchURL *url.URL
	PushURL  *url.URL
}

Remote is a parsed git remote

func AddRemote

func AddRemote(name, u string) (*Remote, error)

AddRemote adds a new git remote and auto-fetches objects from it

func NewRemote

func NewRemote(name string, u string) *Remote

func (*Remote) String

func (r *Remote) String() string

type RemoteSet

type RemoteSet []*Remote

RemoteSet is a slice of git remotes

func Remotes

func Remotes() (RemoteSet, error)

Remotes gets the git remotes set for the current repo

func RemotesForPath added in v2.3.0

func RemotesForPath(path string) (RemoteSet, error)

type SSHAliasMap

type SSHAliasMap map[string]string

SSHAliasMap encapsulates the translation of SSH hostname aliases

func ParseSSHConfig

func ParseSSHConfig() SSHAliasMap

ParseSSHConfig constructs a map of SSH hostname aliases based on user and system configuration files

func (SSHAliasMap) Translator

func (m SSHAliasMap) Translator() func(*url.URL) *url.URL

Translator returns a function that applies hostname aliases to URLs

type TrackingRef

type TrackingRef struct {
	RemoteName string
	BranchName string
}

TrackingRef represents a ref for a remote tracking branch

func (TrackingRef) String

func (r TrackingRef) String() string

Jump to

Keyboard shortcuts

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