Documentation ¶
Index ¶
- Constants
- func Add(g Interface, dir string, args ...string) error
- func AddAndCommitFiles(gitter Interface, dir, message string) (bool, error)
- func AddRemote(g Interface, dir string, name string, url string) error
- func Branch(g Interface, dir string) (string, error)
- func Checkout(g Interface, dir string, branch string) error
- func CheckoutRemoteBranch(g Interface, dir string, branch string) error
- func CloneOrPull(g Interface, url string, dir string) error
- func CloneToDir(g Interface, gitURL, dir string) (string, error)
- func CommitIfChanges(g Interface, dir string, message string) error
- func CreateBranch(gitter Interface, dir string) (string, error)
- func CreateBranchFrom(g Interface, dir string, branchName string, startPoint string) error
- func Describe(g Interface, dir string, contains bool, commitish string, abbrev string, ...) (string, string, error)
- func EnsureUserAndEmailSetup(gitter Interface, dir string, gitUserName string, gitUserEmail string) (string, string, error)
- func FetchBranch(g Interface, dir string, repo string, refspecs ...string) error
- func FetchRemoteTags(g Interface, dir string, repo string) error
- func FetchTags(g Interface, dir string) error
- func FilterTags(g Interface, dir string, filter string) ([]string, error)
- func FindGitConfigDir(dir string) (string, string, error)
- func ForcePushBranch(g Interface, dir string, localBranch string, remoteBranch string) error
- func GetCommitPointedToByLatestTag(g Interface, dir string) (string, string, error)
- func GetLatestCommitMessage(g Interface, dir string) (string, error)
- func GetLatestCommitSha(g Interface, dir string) (string, error)
- func HasChanges(g Interface, dir string) (bool, error)
- func HasFileChanged(g Interface, dir string, fileName string) (bool, error)
- func Init(g Interface, dir string) error
- func Merge(g Interface, dir string, commitish string) error
- func NthTag(g Interface, dir string, n int) (string, string, error)
- func Pull(g Interface, dir string) error
- func Push(g Interface, dir string, remote string, force bool, refspec ...string) error
- func RefIsBranch(gitter Interface, dir string, ref string) (bool, error)
- func RemoteBranches(gitter Interface, dir string) ([]string, error)
- func Remove(g Interface, dir, fileName string) error
- func SetCredentialHelper(gitter Interface, dir string) error
- func SetUpstreamTo(g Interface, dir string, branch string) error
- func SetUserAndEmail(gitter Interface, dir string, gitUserName string, gitUserEmail string, ...) (string, string, error)
- func ShallowCloneBranch(g Interface, gitURL string, branch string, dir string) error
- func Status(g Interface, dir string) (string, error)
- func Tags(g Interface, dir string) ([]string, error)
- type Interface
Constants ¶
const ( // DefaultGitUserName default value to use for git "user.name" DefaultGitUserName = "jenkins-x-bot" // DefaultGitUserEmail default value to use for git "user.email" DefaultGitUserEmail = "jenkins-x@googlegroups.com" )
Variables ¶
This section is empty.
Functions ¶
func AddAndCommitFiles ¶ added in v1.0.59
AddAndCommitFiles add and commits files
func Branch ¶ added in v1.0.60
Branch returns the current branch of the repository located at the given directory
func CheckoutRemoteBranch ¶ added in v1.0.62
CheckoutRemoteBranch checks out the given remote tracking branch
func CloneOrPull ¶ added in v1.0.62
CloneOrPull performs a clone if the directory is empty otherwise a pull
func CloneToDir ¶
CloneToDir clones the git repository to either the given directory or create a temporary
func CommitIfChanges ¶
CommiIfChanges does a commit if there are any changes in the repository at the given directory
func CreateBranch ¶ added in v1.0.59
CreateBranch creates a dynamic branch name and branch
func CreateBranchFrom ¶ added in v1.0.62
CreateBranchFrom creates a new branch called branchName from startPoint
func Describe ¶
func Describe(g Interface, dir string, contains bool, commitish string, abbrev string, fallback bool) (string, string, error)
Describe does a git describe of commitish, optionally adding the abbrev arg if not empty, falling back to just the commit ref if it's untagged
func EnsureUserAndEmailSetup ¶
func EnsureUserAndEmailSetup(gitter Interface, dir string, gitUserName string, gitUserEmail string) (string, string, error)
EnsureUserAndEmailSetup returns the user name and email for the gitter lazily setting them if they are blank either from the given values or if they are empty using environment variables `GIT_AUTHOR_NAME` and `GIT_AUTHOR_EMAIL` or using default values
func FetchBranch ¶ added in v1.0.62
FetchBranch fetches the refspecs from the repo
func FetchRemoteTags ¶ added in v1.0.62
FetchRemoteTags fetches all the tags from a remote repository
func FilterTags ¶ added in v1.0.62
FilterTags returns all tags from the repository at the given directory that match the filter
func FindGitConfigDir ¶
FindGitConfigDir tries to find the `.git` directory either in the current directory or in parent directories
func ForcePushBranch ¶ added in v1.0.60
ForcePushBranch does a force push of the local branch into the remote branch of the repository at the given directory
func GetCommitPointedToByLatestTag ¶
GetCommitPointedToByLatestTag return the SHA of the commit pointed to by the latest git tag as well as the tag name for the git repo in dir
func GetLatestCommitMessage ¶ added in v1.0.62
GetLatestCommitMessage returns the latest git commit message
func GetLatestCommitSha ¶ added in v1.0.60
GetLatestCommitSha returns the latest commit sha
func HasChanges ¶
HasChanges indicates if there are any changes in the repository from the given directory
func HasFileChanged ¶
HasFileChanged indicates if there are any changes to a file in the repository from the given directory
func NthTag ¶
NthTag return the SHA and tag name of nth tag in reverse chronological order from the repository at the given directory. If the nth tag does not exist empty strings without an error are returned.
func RefIsBranch ¶
RefIsBranch looks for remove branches in ORIGIN for the provided directory and returns true if ref is found
func RemoteBranches ¶
RemoteBranches returns the remote branches
func Remove ¶ added in v1.0.62
Remove removes the given file from a Git repository located at the given directory
func SetCredentialHelper ¶
SetCredentialHelper sets the credential store so that we detect the ~/git/credentials file for defaulting access tokens.
If the dir parameter is blank we will use the home dir
func SetUpstreamTo ¶ added in v1.0.62
SetUpstreamTo will set the given branch to track the origin branch with the same name
func SetUserAndEmail ¶ added in v1.0.47
func SetUserAndEmail(gitter Interface, dir string, gitUserName string, gitUserEmail string, assumeInCluster bool) (string, string, error)
SetUserAndEmail sets the user and email if they have not been set Uses environment variables `GIT_AUTHOR_NAME` and `GIT_AUTHOR_EMAIL`
func ShallowCloneBranch ¶
ShallowCloneBranch clones a single branch of the given git URL into the given directory
Types ¶
type Interface ¶
type Interface interface { // Command command runs the git sub command such as 'commit' or 'clone' // in the given directory with the arguments Command(dir string, args ...string) (string, error) }
Interface a simple interface to performing git commands which is easy to fake for testing