git

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 13 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func CommitBody added in v0.6.2

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 ParseURL

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

ParseURL normalizes git remote urls

func Push

func Push(remote string, ref string) error

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

func ToplevelDir

func ToplevelDir() (string, error)

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

func UncommittedChangeCount

func UncommittedChangeCount() (int, 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 added in v0.6.2

type Commit struct {
	Sha   string
	Title string
}

func Commits added in v0.6.2

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

type Ref added in v0.6.3

type Ref struct {
	Hash string
	Name string
}

Ref represents a git commit reference

func ShowRefs added in v0.6.3

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

ShowRefs resolves fully-qualified refs to commit hashes

type Remote

type Remote struct {
	Name     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 (*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

type TrackingRef added in v0.6.3

type TrackingRef struct {
	RemoteName string
	BranchName string
}

TrackingRef represents a ref for a remote tracking branch

func (TrackingRef) String added in v0.6.3

func (r TrackingRef) String() string

Jump to

Keyboard shortcuts

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