Documentation ¶
Overview ¶
Package git provides a client to plugins that can do git operations.
Index ¶
- type Client
- type GitTokenGenerator
- type Repo
- func (r *Repo) Am(path string) error
- func (r *Repo) BranchExists(branch string) bool
- func (r *Repo) Checkout(commitlike string) error
- func (r *Repo) CheckoutNewBranch(branch string) error
- func (r *Repo) CheckoutPullRequest(number int) error
- func (r *Repo) Clean() error
- func (r *Repo) Config(args ...string) error
- func (r *Repo) Diff(head, sha string) (changes []string, err error)
- func (r *Repo) Directory() string
- func (r *Repo) Fetch(arg ...string) error
- func (r *Repo) IsDirty() (bool, error)
- func (r *Repo) Merge(commitlike string) (bool, error)
- func (r *Repo) MergeAndCheckout(baseSHA string, mergeStrategy types.PullRequestMergeType, headSHAs ...string) error
- func (r *Repo) MergeCommitsExistBetween(target, head string) (bool, error)
- func (r *Repo) MergeWithStrategy(commitlike string, mergeStrategy types.PullRequestMergeType) (bool, error)
- func (r *Repo) Push(branch string, force bool) error
- func (r *Repo) PushToNamedFork(forkName, branch string, force bool) error
- func (r *Repo) ResetHard(commitlike string) error
- func (r *Repo) RevParse(commitlike string) (string, error)
- func (r *Repo) SetGit(git string)
- func (r *Repo) SetLogger(logger *logrus.Entry)
- func (r *Repo) ShowRef(commitlike string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client can clone repos. It keeps a local cache, so successive clones of the same repo should be quick. Create with NewClient. Be sure to clean it up.
func NewClient ¶
NewClient returns a client that talks to GitHub. It will fail if git is not in the PATH.
func NewClientWithHost ¶
NewClientWithHost creates a client with specified host.
func (*Client) Clone ¶
Clone clones a repository. Pass the full repository name, such as "kubernetes/test-infra" as the repo. This function may take a long time if it is the first time cloning the repo. In that case, it must do a full git mirror clone. For large repos, this can take a while. Once that is done, it will do a git fetch instead of a clone, which will usually take at most a few seconds.
func (*Client) SetCredentials ¶
func (c *Client) SetCredentials(user string, tokenGenerator GitTokenGenerator)
SetCredentials sets credentials in the client to be used for pushing to or pulling from remote repositories.
type GitTokenGenerator ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is a clone of a git repository. Create with Client.Clone, and don't forget to clean it up after.
func (*Repo) Am ¶
Am tries to apply the patch in the given path into the current branch by performing a three-way merge (similar to git cherry-pick). It returns an error if the patch cannot be applied.
func (*Repo) BranchExists ¶
BranchExists returns true if branch exists in heads.
func (*Repo) CheckoutNewBranch ¶
CheckoutNewBranch creates a new branch and checks it out.
func (*Repo) CheckoutPullRequest ¶
CheckoutPullRequest does exactly that.
func (*Repo) Diff ¶
Diff runs 'git diff HEAD <sha> --name-only' and returns a list of file names with upcoming changes
func (*Repo) Merge ¶
Merge attempts to merge commitlike into the current branch. It returns true if the merge completes. It returns an error if the abort fails.
func (*Repo) MergeAndCheckout ¶
func (r *Repo) MergeAndCheckout(baseSHA string, mergeStrategy types.PullRequestMergeType, headSHAs ...string) error
MergeAndCheckout merges the provided headSHAs in order onto baseSHA using the provided strategy. If no headSHAs are provided, it will only checkout the baseSHA and return. Only the `merge` and `squash` strategies are supported.
func (*Repo) MergeCommitsExistBetween ¶
MergeCommitsExistBetween runs 'git log <target>..<head> --merged' to verify if merge commits exist between "target" and "head".
func (*Repo) MergeWithStrategy ¶
func (r *Repo) MergeWithStrategy(commitlike string, mergeStrategy types.PullRequestMergeType) (bool, error)
MergeWithStrategy attempts to merge commitlike into the current branch given the merge strategy. It returns true if the merge completes. It returns an error if the abort fails.
func (*Repo) Push ¶
Push pushes over https to the provided owner/repo#branch using a password for basic auth.