gitclient

package
v1.0.43 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
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 AddRemote

func AddRemote(g Interface, dir string, name string, url string) error

AddRemote adds a remote repository at the given URL and with the given name

func CloneToDir

func CloneToDir(g Interface, gitURL, dir string) (string, error)

CloneToDir clones the git repository to either the given directory or create a temporary

func CommitIfChanges

func CommitIfChanges(g Interface, dir string, message string) error

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

func FindGitConfigDir(dir string) (string, string, error)

FindGitConfigDir tries to find the `.git` directory either in the current directory or in parent directories

func GetCommitPointedToByLatestTag

func GetCommitPointedToByLatestTag(g Interface, dir string) (string, string, error)

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

func HasChanges(g Interface, dir string) (bool, error)

HasChanges indicates if there are any changes in the repository from the given directory

func HasFileChanged

func HasFileChanged(g Interface, dir string, fileName string) (bool, error)

HasFileChanged indicates if there are any changes to a file in the repository from the given directory

func NthTag

func NthTag(g Interface, dir string, n int) (string, string, error)

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

func RefIsBranch(gitter Interface, dir string, ref string) (bool, error)

RefIsBranch looks for remove branches in ORIGIN for the provided directory and returns true if ref is found

func RemoteBranches

func RemoteBranches(gitter Interface, dir string) ([]string, error)

RemoteBranches returns the remote branches

func SetCredentialHelper

func SetCredentialHelper(gitter Interface, dir string) error

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 ShallowCloneBranch

func ShallowCloneBranch(g Interface, gitURL string, branch string, dir string) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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