Documentation ¶
Overview ¶
Package gitutil provides Go wrappers for various Git commands.
Index ¶
- type AuthorDateOpt
- type CheckoutOpt
- type CommitOpt
- type Committer
- type CommitterDateOpt
- type DeleteBranchOpt
- type FetchOpt
- type FollowTagsOpt
- type ForceOpt
- type Git
- func (g *Git) Add(file string) error
- func (g *Git) AddRemote(name, path string) error
- func (g *Git) BranchExists(branch string) bool
- func (g *Git) BranchesDiffer(branch1, branch2 string) (bool, error)
- func (g *Git) CheckoutBranch(branch string, opts ...CheckoutOpt) error
- func (g *Git) Clone(repo, path string) error
- func (g *Git) CloneRecursive(repo, path string) error
- func (g *Git) Commit() error
- func (g *Git) CommitAmend() error
- func (g *Git) CommitAmendWithMessage(message string) error
- func (g *Git) CommitAndEdit() error
- func (g *Git) CommitFile(fileName, message string) error
- func (g *Git) CommitMessages(branch, baseBranch string) (string, error)
- func (g *Git) CommitNoVerify(message string) error
- func (g *Git) CommitWithMessage(message string) error
- func (g *Git) CommitWithMessageAndEdit(message string) error
- func (g *Git) Committers() ([]string, error)
- func (g *Git) CountCommits(branch, base string) (int, error)
- func (g *Git) CreateAndCheckoutBranch(branch string) error
- func (g *Git) CreateBranch(branch string) error
- func (g *Git) CreateBranchWithUpstream(branch, upstream string) error
- func (g *Git) CurrentBranchName() (string, error)
- func (g *Git) CurrentRevision() (string, error)
- func (g *Git) CurrentRevisionOfBranch(branch string) (string, error)
- func (g *Git) DeleteBranch(branch string, opts ...DeleteBranchOpt) error
- func (g *Git) DirExistsOnBranch(dir, branch string) bool
- func (g *Git) Fetch(remote string, opts ...FetchOpt) error
- func (g *Git) FetchRefspec(remote, refspec string, opts ...FetchOpt) error
- func (g *Git) FilesWithUncommittedChanges() ([]string, error)
- func (g *Git) GetBranches(args ...string) ([]string, string, error)
- func (g *Git) HasUncommittedChanges() (bool, error)
- func (g *Git) HasUntrackedFiles() (bool, error)
- func (g *Git) Init(path string) error
- func (g *Git) IsFileCommitted(file string) bool
- func (g *Git) LatestCommitMessage() (string, error)
- func (g *Git) Log(branch, base, format string) ([][]string, error)
- func (g *Git) Merge(branch string, opts ...MergeOpt) error
- func (g *Git) MergeInProgress() (bool, error)
- func (g *Git) ModifiedFiles(baseBranch, currentBranch string) ([]string, error)
- func (g *Git) NewCommitter(edit bool) *Committer
- func (g *Git) Pull(remote, branch string) error
- func (g *Git) Push(remote, branch string, opts ...PushOpt) error
- func (g *Git) Rebase(upstream string) error
- func (g *Git) RebaseAbort() error
- func (g *Git) RemoteUrl(name string) (string, error)
- func (g *Git) Remove(fileNames ...string) error
- func (g *Git) RemoveUntrackedFiles() error
- func (g *Git) Reset(target string, opts ...ResetOpt) error
- func (g *Git) SetRemoteUrl(name, url string) error
- func (g *Git) Stash() (bool, error)
- func (g *Git) StashPop() error
- func (g *Git) StashSize() (int, error)
- func (g *Git) TopLevel() (string, error)
- func (g *Git) TrackedFiles() ([]string, error)
- func (g *Git) UntrackedFiles() ([]string, error)
- func (g *Git) Version() (int, int, error)
- type GitError
- type MergeOpt
- type MessageOpt
- type ModeOpt
- type PushOpt
- type ResetOnFailureOpt
- type ResetOpt
- type RootDirOpt
- type SquashOpt
- type StrategyOpt
- type TagsOpt
- type VerifyOpt
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 Committer ¶
type Committer struct {
// contains filtered or unexported fields
}
Committer encapsulates the process of create a commit.
type CommitterDateOpt ¶
type CommitterDateOpt string
type DeleteBranchOpt ¶
type DeleteBranchOpt interface {
// contains filtered or unexported methods
}
type FollowTagsOpt ¶
type FollowTagsOpt bool
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
func (*Git) BranchExists ¶
BranchExists tests whether a branch with the given name exists in the local repository.
func (*Git) BranchesDiffer ¶
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) CloneRecursive ¶
CloneRecursive clones the given repository recursively to the given local path.
func (*Git) CommitAmend ¶
CommitAmend amends the previous commit with the currently staged changes. Empty commits are allowed.
func (*Git) CommitAmendWithMessage ¶
CommitAmendWithMessage amends the previous commit with the currently staged changes, and the given message. Empty commits are allowed.
func (*Git) CommitAndEdit ¶
CommitAndEdit commits all files in staging and allows the user to edit the commit message.
func (*Git) CommitFile ¶
CommitFile commits the given file with the given commit message.
func (*Git) CommitMessages ¶
CommitMessages returns the concatenation of all commit messages on <branch> that are not also on <baseBranch>.
func (*Git) CommitNoVerify ¶
CommitNoVerify commits all files in staging with the given message and skips all git-hooks.
func (*Git) CommitWithMessage ¶
CommitWithMessage commits all files in staging with the given message.
func (*Git) CommitWithMessageAndEdit ¶
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 ¶
Committers returns a list of committers for the current repository along with the number of their commits.
func (*Git) CountCommits ¶
CountCommits returns the number of commits on <branch> that are not on <base>.
func (*Git) CreateAndCheckoutBranch ¶
CreateAndCheckoutBranch creates a new branch with the given name and checks it out.
func (*Git) CreateBranch ¶
CreateBranch creates a new branch with the given name.
func (*Git) CreateBranchWithUpstream ¶
CreateBranchWithUpstream creates a new branch and sets the upstream repository to the given upstream.
func (*Git) CurrentBranchName ¶
CurrentBranchName returns the name of the current branch.
func (*Git) CurrentRevision ¶
CurrentRevision returns the current revision.
func (*Git) CurrentRevisionOfBranch ¶
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 ¶
DirExistsOnBranch returns true if a directory with the given name exists on the branch. If branch is empty it defaults to "master".
func (*Git) FetchRefspec ¶
FetchRefspec fetches refs and tags from the given remote for a particular refspec.
func (*Git) FilesWithUncommittedChanges ¶
FilesWithUncommittedChanges returns the list of files that have uncommitted changes.
func (*Git) GetBranches ¶
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 ¶
HasUncommittedChanges checks whether the current branch contains any uncommitted changes.
func (*Git) HasUntrackedFiles ¶
HasUntrackedFiles checks whether the current branch contains any untracked files.
func (*Git) IsFileCommitted ¶
IsFileCommitted tests whether the given file has been committed to the repository.
func (*Git) LatestCommitMessage ¶
LatestCommitMessage returns the latest commit message on the current branch.
func (*Git) Log ¶
Log returns a list of commits on <branch> that are not on <base>, using the specified format.
func (*Git) Merge ¶
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 ¶
MergeInProgress returns a boolean flag that indicates if a merge operation is in progress for the current repository.
func (*Git) ModifiedFiles ¶
ModifiedFiles returns a slice of filenames that have changed between <baseBranch> and <currentBranch>.
func (*Git) NewCommitter ¶
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) RebaseAbort ¶
RebaseAbort aborts an in-progress rebase operation.
func (*Git) RemoveUntrackedFiles ¶
RemoveUntrackedFiles removes untracked files and directories.
func (*Git) Reset ¶
Reset resets the current branch to the target, discarding any uncommitted changes.
func (*Git) SetRemoteUrl ¶
SetRemoteUrl sets the url of the remote with given name to the given url.
func (*Git) Stash ¶
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) TrackedFiles ¶
TrackedFiles returns the list of files that are tracked.
func (*Git) UntrackedFiles ¶
UntrackedFiles returns the list of files that are not tracked.
type MessageOpt ¶
type MessageOpt string
type ResetOnFailureOpt ¶
type ResetOnFailureOpt bool
type RootDirOpt ¶
type RootDirOpt string
type StrategyOpt ¶
type StrategyOpt string