git

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitCommand = func(args ...string) *exec.Cmd {
	return exec.Command("git", args...)
}

Functions

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 ParseURL

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

ParseURL normalizes git remote urls

func Push

func Push(remote string, ref 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 VerifyRef

func VerifyRef(ref string) bool

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 Remote

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

Remote is a parsed git remote

func AddRemote added in v0.5.0

func AddRemote(name, initURL, finalURL string) (*Remote, error)

AddRemote adds a new git remote. The initURL is the remote URL with which the automatic fetch is made and finalURL, if non-blank, is set as the remote URL after the fetch.

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

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

Jump to

Keyboard shortcuts

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