gitutil

package
v0.0.0-...-abfb8b1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package gitutil provides Go wrappers for various Git commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorDateOpt

type AuthorDateOpt string

type CheckoutOpt

type CheckoutOpt interface {
	// contains filtered or unexported methods
}

type CommitOpt

type CommitOpt interface {
	// contains filtered or unexported methods
}

type Committer

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

Committer encapsulates the process of create a commit.

func (*Committer) Commit

func (c *Committer) Commit(message string) error

Commit creates a commit.

type CommitterDateOpt

type CommitterDateOpt string

type DeleteBranchOpt

type DeleteBranchOpt interface {
	// contains filtered or unexported methods
}

type FetchOpt

type FetchOpt interface {
	// contains filtered or unexported methods
}

type FollowTagsOpt

type FollowTagsOpt bool

type ForceOpt

type ForceOpt bool

type Git

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

func New

func New(s runutil.Sequence, opts ...gitOpt) *Git

New is the Git factory.

func (*Git) Add

func (g *Git) Add(file string) error

Add adds a file to staging.

func (*Git) AddRemote

func (g *Git) AddRemote(name, path string) error

AddRemote adds a new remote with the given name and path.

func (*Git) BranchExists

func (g *Git) BranchExists(branch string) bool

BranchExists tests whether a branch with the given name exists in the local repository.

func (*Git) BranchesDiffer

func (g *Git) BranchesDiffer(branch1, branch2 string) (bool, error)

BranchesDiffer tests whether two branches have any changes between them.

func (*Git) CheckoutBranch

func (g *Git) CheckoutBranch(branch string, opts ...CheckoutOpt) error

CheckoutBranch checks out the given branch.

func (*Git) Clone

func (g *Git) Clone(repo, path string) error

Clone clones the given repository to the given local path.

func (*Git) CloneRecursive

func (g *Git) CloneRecursive(repo, path string) error

CloneRecursive clones the given repository recursively to the given local path.

func (*Git) Commit

func (g *Git) Commit() error

Commit commits all files in staging with an empty message.

func (*Git) CommitAmend

func (g *Git) CommitAmend() error

CommitAmend amends the previous commit with the currently staged changes. Empty commits are allowed.

func (*Git) CommitAmendWithMessage

func (g *Git) CommitAmendWithMessage(message string) error

CommitAmendWithMessage amends the previous commit with the currently staged changes, and the given message. Empty commits are allowed.

func (*Git) CommitAndEdit

func (g *Git) CommitAndEdit() error

CommitAndEdit commits all files in staging and allows the user to edit the commit message.

func (*Git) CommitFile

func (g *Git) CommitFile(fileName, message string) error

CommitFile commits the given file with the given commit message.

func (*Git) CommitMessages

func (g *Git) CommitMessages(branch, baseBranch string) (string, error)

CommitMessages returns the concatenation of all commit messages on <branch> that are not also on <baseBranch>.

func (*Git) CommitNoVerify

func (g *Git) CommitNoVerify(message string) error

CommitNoVerify commits all files in staging with the given message and skips all git-hooks.

func (*Git) CommitWithMessage

func (g *Git) CommitWithMessage(message string) error

CommitWithMessage commits all files in staging with the given message.

func (*Git) CommitWithMessageAndEdit

func (g *Git) CommitWithMessageAndEdit(message string) error

CommitWithMessage commits all files in staging and allows the user to edit the commit message. The given message will be used as the default.

func (*Git) Committers

func (g *Git) Committers() ([]string, error)

Committers returns a list of committers for the current repository along with the number of their commits.

func (*Git) CountCommits

func (g *Git) CountCommits(branch, base string) (int, error)

CountCommits returns the number of commits on <branch> that are not on <base>.

func (*Git) CreateAndCheckoutBranch

func (g *Git) CreateAndCheckoutBranch(branch string) error

CreateAndCheckoutBranch creates a new branch with the given name and checks it out.

func (*Git) CreateBranch

func (g *Git) CreateBranch(branch string) error

CreateBranch creates a new branch with the given name.

func (*Git) CreateBranchWithUpstream

func (g *Git) CreateBranchWithUpstream(branch, upstream string) error

CreateBranchWithUpstream creates a new branch and sets the upstream repository to the given upstream.

func (*Git) CurrentBranchName

func (g *Git) CurrentBranchName() (string, error)

CurrentBranchName returns the name of the current branch.

func (*Git) CurrentRevision

func (g *Git) CurrentRevision() (string, error)

CurrentRevision returns the current revision.

func (*Git) CurrentRevisionOfBranch

func (g *Git) CurrentRevisionOfBranch(branch string) (string, error)

CurrentRevisionOfBranch returns the current revision of the given branch.

func (*Git) DeleteBranch

func (g *Git) DeleteBranch(branch string, opts ...DeleteBranchOpt) error

DeleteBranch deletes the given branch.

func (*Git) DirExistsOnBranch

func (g *Git) DirExistsOnBranch(dir, branch string) bool

DirExistsOnBranch returns true if a directory with the given name exists on the branch. If branch is empty it defaults to "master".

func (*Git) Fetch

func (g *Git) Fetch(remote string, opts ...FetchOpt) error

Fetch fetches refs and tags from the given remote.

func (*Git) FetchRefspec

func (g *Git) FetchRefspec(remote, refspec string, opts ...FetchOpt) error

FetchRefspec fetches refs and tags from the given remote for a particular refspec.

func (*Git) FilesWithUncommittedChanges

func (g *Git) FilesWithUncommittedChanges() ([]string, error)

FilesWithUncommittedChanges returns the list of files that have uncommitted changes.

func (*Git) GetBranches

func (g *Git) GetBranches(args ...string) ([]string, string, error)

GetBranches returns a slice of the local branches of the current repository, followed by the name of the current branch. The behavior can be customized by providing optional arguments (e.g. --merged).

func (*Git) HasUncommittedChanges

func (g *Git) HasUncommittedChanges() (bool, error)

HasUncommittedChanges checks whether the current branch contains any uncommitted changes.

func (*Git) HasUntrackedFiles

func (g *Git) HasUntrackedFiles() (bool, error)

HasUntrackedFiles checks whether the current branch contains any untracked files.

func (*Git) Init

func (g *Git) Init(path string) error

Init initializes a new git repository.

func (*Git) IsFileCommitted

func (g *Git) IsFileCommitted(file string) bool

IsFileCommitted tests whether the given file has been committed to the repository.

func (*Git) LatestCommitMessage

func (g *Git) LatestCommitMessage() (string, error)

LatestCommitMessage returns the latest commit message on the current branch.

func (*Git) Log

func (g *Git) Log(branch, base, format string) ([][]string, error)

Log returns a list of commits on <branch> that are not on <base>, using the specified format.

func (*Git) Merge

func (g *Git) Merge(branch string, opts ...MergeOpt) error

Merge merges all commits from <branch> to the current branch. If <squash> is set, then all merged commits are squashed into a single commit.

func (*Git) MergeInProgress

func (g *Git) MergeInProgress() (bool, error)

MergeInProgress returns a boolean flag that indicates if a merge operation is in progress for the current repository.

func (*Git) ModifiedFiles

func (g *Git) ModifiedFiles(baseBranch, currentBranch string) ([]string, error)

ModifiedFiles returns a slice of filenames that have changed between <baseBranch> and <currentBranch>.

func (*Git) NewCommitter

func (g *Git) NewCommitter(edit bool) *Committer

NewCommitter is the Committer factory. The boolean <edit> flag determines whether the commit commands should prompt users to edit the commit message. This flag enables automated testing.

func (*Git) Pull

func (g *Git) Pull(remote, branch string) error

Pull pulls the given branch from the given remote.

func (*Git) Push

func (g *Git) Push(remote, branch string, opts ...PushOpt) error

Push pushes the given branch to the given remote.

func (*Git) Rebase

func (g *Git) Rebase(upstream string) error

Rebase rebases to a particular upstream branch.

func (*Git) RebaseAbort

func (g *Git) RebaseAbort() error

RebaseAbort aborts an in-progress rebase operation.

func (*Git) RemoteUrl

func (g *Git) RemoteUrl(name string) (string, error)

RemoteUrl gets the url of the remote with the given name.

func (*Git) Remove

func (g *Git) Remove(fileNames ...string) error

Remove removes the given files.

func (*Git) RemoveUntrackedFiles

func (g *Git) RemoveUntrackedFiles() error

RemoveUntrackedFiles removes untracked files and directories.

func (*Git) Reset

func (g *Git) Reset(target string, opts ...ResetOpt) error

Reset resets the current branch to the target, discarding any uncommitted changes.

func (*Git) SetRemoteUrl

func (g *Git) SetRemoteUrl(name, url string) error

SetRemoteUrl sets the url of the remote with given name to the given url.

func (*Git) Stash

func (g *Git) Stash() (bool, error)

Stash attempts to stash any unsaved changes. It returns true if anything was actually stashed, otherwise false. An error is returned if the stash command fails.

func (*Git) StashPop

func (g *Git) StashPop() error

StashPop pops the stash into the current working tree.

func (*Git) StashSize

func (g *Git) StashSize() (int, error)

StashSize returns the size of the stash stack.

func (*Git) TopLevel

func (g *Git) TopLevel() (string, error)

TopLevel returns the top level path of the current repository.

func (*Git) TrackedFiles

func (g *Git) TrackedFiles() ([]string, error)

TrackedFiles returns the list of files that are tracked.

func (*Git) UntrackedFiles

func (g *Git) UntrackedFiles() ([]string, error)

UntrackedFiles returns the list of files that are not tracked.

func (*Git) Version

func (g *Git) Version() (int, int, error)

Version returns the major and minor git version.

type GitError

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

func Error

func Error(output, errorOutput string, args ...string) GitError

func (GitError) Error

func (ge GitError) Error() string

type MergeOpt

type MergeOpt interface {
	// contains filtered or unexported methods
}

type MessageOpt

type MessageOpt string

type ModeOpt

type ModeOpt string

type PushOpt

type PushOpt interface {
	// contains filtered or unexported methods
}

type ResetOnFailureOpt

type ResetOnFailureOpt bool

type ResetOpt

type ResetOpt interface {
	// contains filtered or unexported methods
}

type RootDirOpt

type RootDirOpt string

type SquashOpt

type SquashOpt bool

type StrategyOpt

type StrategyOpt string

type TagsOpt

type TagsOpt bool

type VerifyOpt

type VerifyOpt bool

Jump to

Keyboard shortcuts

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