Documentation
¶
Overview ¶
Package gitutil provides Go wrappers for various Git commands.
Index ¶
- Constants
- type AllOpt
- type AuthorDateOpt
- type BareOpt
- type Branch
- type BranchName
- type CheckoutOpt
- type CloneOpt
- type CommitOpt
- type Committer
- type CommitterDateOpt
- type DeleteBranchOpt
- type DepthOpt
- type DetachOpt
- type FetchOpt
- type FetchTagOpt
- type FfOnlyOpt
- type FollowTagsOpt
- type ForceOpt
- type Git
- func (g *Git) Add(file string) error
- func (g *Git) AddOrReplaceRemote(name, path string) error
- func (g *Git) AddRemote(name, path string) error
- func (g *Git) AddUpdatedFiles() error
- func (g *Git) BranchExists(branch string) (bool, error)
- func (g *Git) BranchesDiffer(branch1, branch2 string) (bool, error)
- func (g *Git) CheckoutBranch(branch string, opts ...CheckoutOpt) error
- func (g *Git) CherryPick(rev string) error
- func (g *Git) CherryPickAbort() error
- func (g *Git) Clone(repo, path string, opts ...CloneOpt) error
- func (g *Git) CloneMirror(repo, path string, depth int) 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) CommitMsg(ref 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) Config(configArgs ...string) error
- func (g *Git) ConfigGetKey(key string) (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) CreateBranchFromRef(branch, ref string) error
- func (g *Git) CreateBranchWithUpstream(branch, upstream string) error
- func (g *Git) CreateLightweightTag(name string) error
- func (g *Git) CurrentBranchName() (string, error)
- func (g *Git) CurrentRevision() (string, error)
- func (g *Git) CurrentRevisionForRef(ref string) (string, error)
- func (g *Git) CurrentRevisionOfBranch(branch string) (string, error)
- func (g *Git) DeleteBranch(branch string, opts ...DeleteBranchOpt) error
- func (g *Git) DeleteRemote(name string) error
- func (g *Git) DirExistsOnBranch(dir, branch string) bool
- func (g *Git) ExtraCommits(rev, base string) ([]string, error)
- 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) GetAllBranchesInfo() ([]Branch, error)
- func (g *Git) GetBranches(args ...string) ([]string, string, error)
- func (g *Git) GetRemoteBranchesContaining(commit string) ([]string, error)
- func (g *Git) GetSymbolicRef() (string, error)
- func (g *Git) Grep(query string, pathSpecs []string, flags ...string) ([]string, error)
- func (g *Git) HasUncommittedChanges() (bool, error)
- func (g *Git) HasUntrackedFiles() (bool, error)
- func (g *Git) Init(path string, opts ...CloneOpt) error
- func (g *Git) IsFileCommitted(file string) bool
- func (g *Git) IsOnBranch() bool
- func (g *Git) IsRevAvailable(rev string) bool
- func (g *Git) LatestCommitMessage() (string, error)
- func (g *Git) ListBranchesContainingRef(commit string) (map[string]bool, error)
- func (g *Git) ListRemoteBranchesContainingRef(commit string) (map[string]bool, error)
- func (g *Git) Log(branch, base, format string) ([][]string, error)
- func (g *Git) LsRemote(args ...string) (string, error)
- func (g *Git) Merge(branch string, opts ...MergeOpt) error
- func (g *Git) MergedBranches(ref string) ([]string, error)
- func (g *Git) ModifiedFiles(baseBranch, currentBranch string) ([]string, error)
- func (g *Git) NewCommitter(edit bool) *Committer
- func (g *Git) OneLineLog(rev string) (string, error)
- func (g *Git) Pull(remote, branch string) error
- func (g *Git) Push(remote, branch string, opts ...PushOpt) error
- func (g *Git) Rebase(upstream string, opts ...RebaseOpt) error
- func (g *Git) RebaseAbort() error
- func (g *Git) RemoteBranchName() (string, 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) SetUpstream(branch, upstream string) error
- func (g *Git) ShortHash(ref string) (string, error)
- func (g *Git) ShortStatus() (string, error)
- func (g *Git) Show(ref, file string) (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) TrackingBranchFromSymbolicRef(ref string) (string, error)
- func (g *Git) TrackingBranchName() (string, error)
- func (g *Git) UntrackedFiles() ([]string, error)
- func (g *Git) UserInfoForCommit(ref string) (string, string, error)
- func (g *Git) Version() (int, int, error)
- type GitError
- type MergeOpt
- type MessageOpt
- type ModeOpt
- type NoCheckoutOpt
- type OmitBlobsOpt
- type PruneOpt
- type PushOpt
- type RebaseMerges
- type RebaseOpt
- type Reference
- type ReferenceOpt
- type ResetOnFailureOpt
- type ResetOpt
- type Revision
- type RootDirOpt
- type SharedOpt
- type SquashOpt
- type StrategyOpt
- type TagsOpt
- type UpdateShallowOpt
- type UserEmailOpt
- type UserNameOpt
- type VerifyOpt
Constants ¶
const ( RemoteType = "remote" LocalType = "local" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorDateOpt ¶
type AuthorDateOpt string
type BranchName ¶
type BranchName 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 FetchTagOpt ¶
type FetchTagOpt string
type FollowTagsOpt ¶
type FollowTagsOpt bool
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
func (*Git) AddOrReplaceRemote ¶
AddOrReplaceRemote adds a new remote with given name and path. If the name already exists, it replaces the named remote with new path.
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) CherryPick ¶
func (*Git) CherryPickAbort ¶
CherryPickAbort aborts an in-progress cherry-pick operation.
func (*Git) Clone ¶
Clone clones the given repository to the given local path. If reference is not empty it uses the given path as a reference/shared repo.
func (*Git) CloneMirror ¶
CloneMirror clones the given repository using mirror flag.
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) CreateBranchFromRef ¶
CreateBranchFromRef creates a new branch from an existing reference.
func (*Git) CreateBranchWithUpstream ¶
CreateBranchWithUpstream creates a new branch and sets the upstream repository to the given upstream.
func (*Git) CreateLightweightTag ¶
CreateLightweightTag creates a lightweight tag with a given name.
func (*Git) CurrentBranchName ¶
CurrentBranchName returns the name of the current branch.
func (*Git) CurrentRevision ¶
CurrentRevision returns the current revision.
func (*Git) CurrentRevisionForRef ¶
CurrentRevisionForRef gets current rev for ref/branch/tags
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) DeleteRemote ¶
DeleteRemote deletes the named remote
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) ExtraCommits ¶
Provides list of commits reachable from rev but not from base rev can be a branch/tag or revision name.
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) GetAllBranchesInfo ¶
GetAllBranchesInfo returns information about all branches.
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) GetRemoteBranchesContaining ¶
GetRemoteBranchesContaining returns a slice of the remote branches which contains the given commit
func (*Git) GetSymbolicRef ¶
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) IsOnBranch ¶
func (*Git) IsRevAvailable ¶
IsRevAvailable runs cat-file on a commit hash is available locally.
func (*Git) LatestCommitMessage ¶
LatestCommitMessage returns the latest commit message on the current branch.
func (*Git) ListBranchesContainingRef ¶
ListBranchesContainingRef returns a slice of the local branches which contains the given commit
func (*Git) ListRemoteBranchesContainingRef ¶
ListRemoteBranchesContainingRef returns a slice of the remote branches which contains the given commit
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) MergedBranches ¶
MergedBranches returns the list of all branches that were already merged.
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) RemoteBranchName ¶
RemoteBranchName returns the name of the tracking branch stripping remote name from it. It will search recursively if current branch tracks a local branch.
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) SetUpstream ¶
SetUpstream sets the upstream branch to the given one.
func (*Git) ShortStatus ¶
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) TrackingBranchFromSymbolicRef ¶
TrackingBranchFromSymbolicRef returns the name of the tracking branch for provided ref
func (*Git) TrackingBranchName ¶
TrackingBranchName returns the name of the tracking branch.
func (*Git) UntrackedFiles ¶
UntrackedFiles returns the list of files that are not tracked.
func (*Git) UserInfoForCommit ¶
UserInfoForCommit returns user name and email for a given reference.
type GitError ¶
type GitError struct { Root string Args []string Output string ErrorOutput string // contains filtered or unexported fields }
type MessageOpt ¶
type MessageOpt string
type NoCheckoutOpt ¶
type NoCheckoutOpt bool
type OmitBlobsOpt ¶
type OmitBlobsOpt bool
type RebaseMerges ¶
type RebaseMerges bool
type ReferenceOpt ¶
type ReferenceOpt string
type ResetOnFailureOpt ¶
type ResetOnFailureOpt bool
type RootDirOpt ¶
type RootDirOpt string
type StrategyOpt ¶
type StrategyOpt string
type UpdateShallowOpt ¶
type UpdateShallowOpt bool
type UserEmailOpt ¶
type UserEmailOpt string
type UserNameOpt ¶
type UserNameOpt string