Documentation ¶
Index ¶
- Constants
- func AddRemote(g Interface, dir string, name string, url string) error
- func CloneToDir(g Interface, gitURL, dir string) (string, error)
- func CommitIfChanges(g Interface, dir string, message 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 FindGitConfigDir(dir string) (string, string, error)
- func GetCommitPointedToByLatestTag(g Interface, dir string) (string, string, error)
- func HasChanges(g Interface, dir string) (bool, error)
- func HasFileChanged(g Interface, dir string, fileName string) (bool, error)
- func NthTag(g Interface, dir string, n int) (string, string, error)
- func RefIsBranch(gitter Interface, dir string, ref string) (bool, error)
- func RemoteBranches(gitter Interface, dir string) ([]string, error)
- func SetCredentialHelper(gitter Interface, dir string) error
- func ShallowCloneBranch(g Interface, gitURL string, branch string, dir 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 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 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 FindGitConfigDir ¶
FindGitConfigDir tries to find the `.git` directory either in the current directory or in parent directories
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 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 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
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