git

package
v1.7.0-dev-20190926 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Overview

Package git provides handling for the git source control system. Currently it is a thin wrapper over the git command line.

Index

Constants

View Source
const (
	FetchHead = "FETCH_HEAD"
	Head      = "HEAD"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeList

type ChangeList struct {
	SHA         SHA
	Author      string
	Subject     string
	Description string
}

type Git

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

Git is a go-wrapper for the git version control system.

func New

func New(wd string) (Git, error)

New returns a new Git instance targeting the working directory wd.

func (Git) CanApplyPatch

func (g Git) CanApplyPatch(ctx context.Context, patch string) (bool, error)

CanApplyPatch returns true if the specified patch can be applied to HEAD without conficts.

func (Git) Checkout added in v1.1.0

func (g Git) Checkout(ctx context.Context, sha SHA) error

Checkout checks out the given CL by SHA.

func (Git) CheckoutBranch added in v1.1.0

func (g Git) CheckoutBranch(ctx context.Context, branch string) error

CheckoutBranch checks out the given branch by name.

func (Git) CurrentBranch

func (g Git) CurrentBranch(ctx context.Context) (string, error)

CurrentBranch returns the current branch name at HEAD.

func (Git) Fetch

func (g Git) Fetch(ctx context.Context) (localNew, remoteNew int, err error)

Fetch performs a `git fetch` call. The number of new CLs locally and remotely for the current branch is returned.

func (Git) Get

func (g Git) Get(ctx context.Context, path string, at SHA) ([]byte, error)

Get returns a versioned file using `git show` at the specified CL.

func (Git) GetPatch

func (g Git) GetPatch(ctx context.Context, from, to SHA) (string, error)

GetPatch returns the changes between the two SHAs as a patch string.

func (Git) HeadCL

func (g Git) HeadCL(ctx context.Context, at string) (ChangeList, error)

HeadCL returns the HEAD ChangeList at the given commit/tag/branch.

func (Git) Log

func (g Git) Log(ctx context.Context, count int) ([]ChangeList, error)

Log returns the top count ChangeList at HEAD.

func (Git) LogFrom added in v1.1.0

func (g Git) LogFrom(ctx context.Context, at string, count int) ([]ChangeList, error)

LogFrom returns the top count ChangeList starting from at.

func (Git) Parent

func (g Git) Parent(ctx context.Context, cl ChangeList) (ChangeList, error)

Parent returns the parent ChangeList for cl.

func (Git) Rebase

func (g Git) Rebase(ctx context.Context, targetBranch string) error

Rebase performs a `git rebase` on to the target branch.

func (Git) ResetToHead

func (g Git) ResetToHead(ctx context.Context) error

ResetToHead performs a 'git clean -f -d' followed by 'git checkout .'.

func (Git) Status

func (g Git) Status(ctx context.Context) (Status, error)

Status performs a `git status` call.

type SHA

type SHA [20]byte

SHA represents a Git changelist SHA.

func (SHA) IsValid

func (i SHA) IsValid() bool

IsValid returns true if the identifier is non-zero.

func (SHA) MarshalJSON

func (i SHA) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*SHA) Parse

func (i *SHA) Parse(str string) error

Parse parses the identifier string.

func (SHA) String

func (i SHA) String() string

func (*SHA) UnmarshalJSON

func (i *SHA) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Status

type Status struct {
	NotUpdated                []string
	UpdatedInIndex            []string
	AddedToIndex              []string
	DeletedFromIndex          []string
	RenamedInIndex            []string
	CopiedInIndex             []string
	IndexAndWorkTreeMatches   []string
	WorkTreeChangedSinceIndex []string
	DeletedInWorkTree         []string
	UnmergedBothDeleted       []string
	UnmergedAddedByUs         []string
	UnmergedDeletedByThem     []string
	UnmergedAddedByThem       []string
	UnmergedDeletedByUs       []string
	UnmergedBothAdded         []string
	UnmergedBothModified      []string
	Untracked                 []string
	Ignored                   []string
}

func (Status) Clean

func (s Status) Clean() bool

Clean returns true if the status is empty (no file changes).

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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