Back to

Package git

Latest Go to latest
Published: Oct 8, 2017 | License: MIT | Module:


Package Files

func CheckoutUniqueBranch

func CheckoutUniqueBranch(git gateway.Git, prefix, ref string) (name string, err error)

CheckoutUniqueBranch atomically finds a unique branch name and checks it out at the given ref.

The final branch name is returned.

type BulkRebaser

type BulkRebaser struct {
	// contains filtered or unexported fields

BulkRebaser rebases multiple interdependent branches in a safe way. No changes are made to existing branches. Callers can commit changes by retrieving information from RebaseHandles.

r := NewBulkRebaser(g)
defer r.Cleanup()
h := r.Onto("origin/master").Rebase("master", "myfeature")
if err := r.Err(); err != nil {
	return err
g.ResetBranch("myfeature", h.Base())

func NewBulkRebaser

func NewBulkRebaser(g gateway.Git) *BulkRebaser

NewBulkRebaser builds a new Bulk Rebaser.

func (*BulkRebaser) Cleanup

func (br *BulkRebaser) Cleanup() (err error)

Cleanup deletes temporary branches created by the rebaser. The BulkRebaser ceases to be valid after this function has been called. No other operations must be made on the BulkRebaser after this function has been called.

func (*BulkRebaser) Err

func (br *BulkRebaser) Err() error

Err returns a non-nil value if any of the operations on BulkRebaser failed.

Failures encountered during Cleanup are not recorded here.

func (*BulkRebaser) Onto

func (br *BulkRebaser) Onto(ref string) RebaseHandle

Onto starts a new rebase onto the given base. Rebase calls on the returned object will be onto the given ref as base.

For example, the following,

rebaser.Onto("master").Rebase("oldfeature", "newfeature")

Is roughly equivalent to,

git rebase --onto master oldfeature newfeature

This function MUST NOT be called after Cleanup.

type Gateway

type Gateway struct {
	// contains filtered or unexported fields

Gateway is a git gateway.

func NewGateway

func NewGateway(startDir string) (*Gateway, error)

NewGateway builds a new Git gateway.

func (*Gateway) Checkout

func (g *Gateway) Checkout(name string) error

Checkout checks the given branch out.

func (*Gateway) CreateBranch

func (g *Gateway) CreateBranch(name, head string) error

CreateBranch creates a branch with the given name and head but does not check it out.

func (*Gateway) CreateBranchAndCheckout

func (g *Gateway) CreateBranchAndCheckout(name, head string) error

CreateBranchAndCheckout creates a branch with the given name and head and switches to it.

func (*Gateway) CurrentBranch

func (g *Gateway) CurrentBranch() (string, error)

CurrentBranch determines the current branch name.

func (*Gateway) DeleteBranch

func (g *Gateway) DeleteBranch(name string) error

DeleteBranch deletes the given branch.

func (*Gateway) DeleteRemoteTrackingBranch

func (g *Gateway) DeleteRemoteTrackingBranch(remote, name string) error

DeleteRemoteTrackingBranch deletes the remote tracking branch with the given name.

func (*Gateway) DoesBranchExist

func (g *Gateway) DoesBranchExist(name string) bool

DoesBranchExist checks if this branch exists locally.

func (*Gateway) Fetch

func (g *Gateway) Fetch(req *gateway.FetchRequest) error

Fetch a git ref

func (*Gateway) Pull

func (g *Gateway) Pull(remote, name string) error

Pull pulls the given branch.

func (*Gateway) Push

func (g *Gateway) Push(req *gateway.PushRequest) error

Push pushes refs to a remote.

func (*Gateway) Rebase

func (g *Gateway) Rebase(req *gateway.RebaseRequest) error

Rebase a branch.

func (*Gateway) RemoteURL

func (g *Gateway) RemoteURL(name string) (string, error)

RemoteURL gets the URL for the given remote.

func (*Gateway) ResetBranch

func (g *Gateway) ResetBranch(branch, head string) error

ResetBranch resets the given branch to the given head.

func (*Gateway) SHA1

func (g *Gateway) SHA1(ref string) (string, error)

SHA1 gets the SHA1 hash for the given ref.

type RebaseHandle

type RebaseHandle interface {
	// Error, if any, encountered by rebase operations executed in the stack
	// of branches behind this handle.
	Err() error

	// Base on which this handle will rebase items.
	// Empty if a prior operation failed.
	Base() string

	// Rebase requests that the given range of commits be rebased onto the
	// base of this RebaseHandle.
	// A new RebaseHandle is returned whose base is the rebased position of
	// toRef.
	// 	h := rebaser.Onto("dev").Rebase("master", "feature1")
	// h.Base() may now be used to reference the rebased position of feature1,
	// possibly moving it to that position.
	// Any Rebase calls onto the returned RebaseHandle will be against this
	// new base. This allows for rebasing branhes that depend on previously
	// rebased branches.
	// For example, the following rebases the range of commits
	// master..feature1 onto dev and the range feature1..feature2 onto
	// feature1 after it has been rebased.
	// 	rebaser.Onto("dev").
	// 		Rebase("master", "feature1").
	// 		Rebase("feature1", "feature2")
	// This function MUST NOT be called after Cleanup.
	Rebase(fromRef, toRef string) RebaseHandle

RebaseHandle is an ongoing rebase, allowing chaining on more rebase requests.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier