git

package
v0.0.409 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Clean() error
	SetRemote(remote string)
	SetCredentials(user string, tokenGenerator func() []byte)
	Clone(repo string) (*Repo, error)
}

Client represents a git client

func NewClient

func NewClient(serverURL string, gitKind string) (Client, error)

NewClient returns a client that talks to GitHub. It will fail if git is not in the PATH.

type Repo

type Repo struct {
	// Dir is the location of the git repo.
	Dir string
	// contains filtered or unexported fields
}

Repo is a clone of a git repository. Create with Client.Clone, and don't forget to clean it up after.

func (*Repo) Am

func (r *Repo) Am(path string) error

Am tries to apply the patch in the given path into the current branch by performing a three-way merge (similar to git cherry-pick). It returns an error if the patch cannot be applied.

func (*Repo) Checkout

func (r *Repo) Checkout(commitlike string) error

Checkout runs git checkout.

func (*Repo) CheckoutNewBranch

func (r *Repo) CheckoutNewBranch(branch string) error

CheckoutNewBranch creates a new branch and checks it out.

func (*Repo) CheckoutPullRequest

func (r *Repo) CheckoutPullRequest(number int) error

CheckoutPullRequest does exactly that.

func (*Repo) Clean

func (r *Repo) Clean() error

Clean deletes the repo. It is unusable after calling.

func (*Repo) Config

func (r *Repo) Config(key, value string) error

Config runs git config.

func (*Repo) Merge

func (r *Repo) Merge(commitlike string) (bool, error)

Merge attempts to merge commitlike into the current branch. It returns true if the merge completes. It returns an error if the abort fails.

func (*Repo) Push

func (r *Repo) Push(repo, branch string) error

Push pushes over https to the provided owner/repo#branch using a password for basic auth.

func (*Repo) RevParse

func (r *Repo) RevParse(commitlike string) (string, error)

RevParse runs git rev-parse.

Directories

Path Synopsis
Package localgit creates a local git repo that can be used for testing code that uses a git.Client.
Package localgit creates a local git repo that can be used for testing code that uses a git.Client.

Jump to

Keyboard shortcuts

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