Documentation ¶
Index ¶
- Constants
- func ConfigureGlobalDefaultUserAndEmail() error
- func GetDefaultKubernetesRepoURL() string
- func GetKubernetesRepoURL(org string, useSSH bool) string
- func GetRepoURL(org, repo string, useSSH bool) (repoURL string)
- func GetUserEmail() (string, error)
- func GetUserName() (string, error)
- func IsReleaseBranch(branch string) bool
- func LSRemoteExec(repoURL string, args ...string) (string, error)
- func ParseRepoSlug(repoSlug string) (org, repo string, err error)
- func Remotify(name string) string
- type DescribeOptions
- func (d *DescribeOptions) WithAbbrev(abbrev uint8) *DescribeOptions
- func (d *DescribeOptions) WithAlways() *DescribeOptions
- func (d *DescribeOptions) WithDirty() *DescribeOptions
- func (d *DescribeOptions) WithRevision(rev string) *DescribeOptions
- func (d *DescribeOptions) WithTags() *DescribeOptions
- type DiscoverResult
- type NetworkError
- type Remote
- type Repo
- func CleanCloneGitHubRepo(owner, repo string, useSSH bool) (*Repo, error)
- func CloneOrOpenDefaultGitHubRepoSSH(repoPath string) (*Repo, error)
- func CloneOrOpenGitHubRepo(repoPath, owner, repo string, useSSH bool) (*Repo, error)
- func CloneOrOpenRepo(repoPath, repoURL string, useSSH bool) (*Repo, error)
- func OpenRepo(repoPath string) (*Repo, error)
- func (r *Repo) Add(filename string) error
- func (r *Repo) AddRemote(name, owner, repo string) error
- func (r *Repo) Branch(args ...string) (string, error)
- func (r *Repo) Checkout(rev string, args ...string) error
- func (r *Repo) Cleanup() error
- func (r *Repo) Commit(msg string) error
- func (r *Repo) CommitEmpty(msg string) error
- func (r *Repo) CommitWithOptions(msg string, options *git.CommitOptions) error
- func (r *Repo) CurrentBranch() (branch string, err error)
- func (r *Repo) Describe(opts *DescribeOptions) (string, error)
- func (r *Repo) Dir() string
- func (r *Repo) FetchRemote(remoteName string) (bool, error)
- func (r *Repo) HasBranch(branch string) (branchExists bool, err error)
- func (r *Repo) HasRemote(name, expectedURL string) bool
- func (r *Repo) HasRemoteBranch(branch string) (branchExists bool, err error)
- func (r *Repo) HasRemoteTag(tag string) (hasTag bool, err error)
- func (r *Repo) Head() (string, error)
- func (r *Repo) IsDirty() (bool, error)
- func (r *Repo) LatestNonPatchFinalToMinor() (DiscoverResult, error)
- func (r *Repo) LatestPatchToLatest(branch string) (DiscoverResult, error)
- func (r *Repo) LatestPatchToPatch(branch string) (DiscoverResult, error)
- func (r *Repo) LatestReleaseBranchMergeBaseToLatest() (DiscoverResult, error)
- func (r *Repo) LatestTagForBranch(branch string) (tag semver.Version, err error)
- func (r *Repo) LsRemote(args ...string) (output string, err error)
- func (r *Repo) Merge(from string) error
- func (r *Repo) MergeBase(from, to string) (string, error)
- func (r *Repo) PreviousTag(tag, branch string) (string, error)
- func (r *Repo) Push(remoteBranch string) (err error)
- func (r *Repo) PushToRemote(remote, remoteBranch string) error
- func (r *Repo) Rebase(branch string) error
- func (r *Repo) RemoteTags() (tags []string, err error)
- func (r *Repo) Remotes() (res []*Remote, err error)
- func (r *Repo) RevParse(rev string) (string, error)
- func (r *Repo) RevParseShort(rev string) (string, error)
- func (r *Repo) RevParseTag(rev string) (string, error)
- func (r *Repo) RevParseTagShort(rev string) (string, error)
- func (r *Repo) Rm(force bool, files ...string) error
- func (r *Repo) SetDry()
- func (r *Repo) SetInnerRepo(repo Repository)
- func (r *Repo) SetMaxRetries(numRetries int)
- func (r *Repo) SetURL(remote, newURL string) error
- func (r *Repo) SetWorktree(worktree Worktree)
- func (r *Repo) ShowLastCommit() (logData string, err error)
- func (r *Repo) Status() (*git.Status, error)
- func (r *Repo) Tag(name, message string) error
- func (r *Repo) Tags() (res []string, err error)
- func (r *Repo) TagsForBranch(branch string) (res []string, err error)
- func (r *Repo) UserCommit(msg string) error
- type Repository
- type Worktree
Constants ¶
const ( DefaultGithubOrg = "kubernetes" DefaultGithubRepo = "kubernetes" DefaultGithubReleaseRepo = "sig-release" DefaultRemote = "origin" DefaultRef = "HEAD" DefaultBranch = "master" )
Variables ¶
This section is empty.
Functions ¶
func ConfigureGlobalDefaultUserAndEmail ¶ added in v0.6.0
func ConfigureGlobalDefaultUserAndEmail() error
ConfigureGlobalDefaultUserAndEmail globally configures the default git user and email.
func GetDefaultKubernetesRepoURL ¶ added in v0.2.5
func GetDefaultKubernetesRepoURL() string
GetDefaultKubernetesRepoURL returns the default HTTPS repo URL for Kubernetes. Expected: https://github.com/kubernetes/kubernetes
func GetKubernetesRepoURL ¶ added in v0.2.5
GetKubernetesRepoURL takes a GitHub org and repo, and useSSH as a boolean and returns a repo URL for Kubernetes. Expected result is one of the following: - https://github.com/<org>/kubernetes - git@github.com:<org>/kubernetes
func GetRepoURL ¶ added in v0.2.5
GetRepoURL takes a GitHub org and repo, and useSSH as a boolean and returns a repo URL for the specified repo. Expected result is one of the following: - https://github.com/<org>/<repo> - git@github.com:<org>/<repo>
func GetUserEmail ¶ added in v0.4.0
GetUserEmail reads the user's name from git
func GetUserName ¶ added in v0.4.0
GetUserName Reads the local user's name from the git configuration
func IsReleaseBranch ¶
IsReleaseBranch returns true if the provided branch is a Kubernetes release branch
func LSRemoteExec ¶ added in v0.4.2
func ParseRepoSlug ¶ added in v0.4.1
ParseRepoSlug parses a repository string and return the organization and repository name/
Types ¶
type DescribeOptions ¶ added in v0.3.0
type DescribeOptions struct {
// contains filtered or unexported fields
}
DescribeOptions is the type for the argument passed to repo.Describe
func NewDescribeOptions ¶ added in v0.3.0
func NewDescribeOptions() *DescribeOptions
NewDescribeOptions creates new repository describe options
func (*DescribeOptions) WithAbbrev ¶ added in v0.3.0
func (d *DescribeOptions) WithAbbrev(abbrev uint8) *DescribeOptions
WithAbbrev sets the --abbrev=<parameter> in the DescribeOptions
func (*DescribeOptions) WithAlways ¶ added in v0.3.0
func (d *DescribeOptions) WithAlways() *DescribeOptions
WithAlways sets always to true in the DescribeOptions
func (*DescribeOptions) WithDirty ¶ added in v0.3.0
func (d *DescribeOptions) WithDirty() *DescribeOptions
WithDirty sets dirty to true in the DescribeOptions
func (*DescribeOptions) WithRevision ¶ added in v0.3.0
func (d *DescribeOptions) WithRevision(rev string) *DescribeOptions
WithRevision sets the revision in the DescribeOptions
func (*DescribeOptions) WithTags ¶ added in v0.3.0
func (d *DescribeOptions) WithTags() *DescribeOptions
WithTags sets tags to true in the DescribeOptions
type DiscoverResult ¶ added in v0.2.1
type DiscoverResult struct {
// contains filtered or unexported fields
}
DiscoverResult is the result of a revision discovery
func (*DiscoverResult) EndRev ¶ added in v0.2.1
func (d *DiscoverResult) EndRev() string
EndRev returns the end revision for the DiscoverResult
func (*DiscoverResult) EndSHA ¶ added in v0.2.1
func (d *DiscoverResult) EndSHA() string
EndSHA returns the end SHA for the DiscoverResult
func (*DiscoverResult) StartRev ¶ added in v0.2.1
func (d *DiscoverResult) StartRev() string
StartRev returns the start revision for the DiscoverResult
func (*DiscoverResult) StartSHA ¶ added in v0.2.1
func (d *DiscoverResult) StartSHA() string
StartSHA returns the start SHA for the DiscoverResult
type NetworkError ¶ added in v0.5.0
type NetworkError struct {
// contains filtered or unexported fields
}
NetworkError is a wrapper for the error class
func NewNetworkError ¶ added in v0.5.0
func NewNetworkError(err error) NetworkError
NewNetworkError creates a new NetworkError
func (NetworkError) CanRetry ¶ added in v0.5.0
func (e NetworkError) CanRetry() bool
CanRetry tells if an error can be retried
type Remote ¶ added in v0.2.5
type Remote struct {
// contains filtered or unexported fields
}
Remote is a representation of a git remote location
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Wrapper type for a Kubernetes repository instance
func CleanCloneGitHubRepo ¶ added in v0.3.0
CleanCloneGitHubRepo creates a guaranteed fresh checkout of a given repository. The returned *Repo has a Cleanup() method that should be used to delete the repository on-disk afterwards.
func CloneOrOpenDefaultGitHubRepoSSH ¶
CloneOrOpenDefaultGitHubRepoSSH clones the default Kubernetes GitHub repository via SSH if the repoPath is empty, otherwise updates it at the expected repoPath.
func CloneOrOpenGitHubRepo ¶
CloneOrOpenGitHubRepo works with a repository in the given directory, or creates one if the directory is empty. The repo uses the provided GitHub repository via the owner and repo. If useSSH is true, then it will clone the repository using the defaultGithubAuthRoot.
func CloneOrOpenRepo ¶
CloneOrOpenRepo creates a temp directory containing the provided GitHub repository via the url.
If a repoPath is given, then the function tries to update the repository.
The function returns the repository if cloning or updating of the repository was successful, otherwise an error.
func (*Repo) Branch ¶ added in v0.3.0
Branch can be used to run `git branch` with the provided args on the repository
func (*Repo) Checkout ¶ added in v0.2.2
Checkout can be used to checkout any revision inside the repository
func (*Repo) CommitEmpty ¶ added in v0.6.0
CommitEmpty commits an empty commit into the repository
func (*Repo) CommitWithOptions ¶ added in v0.2.7
CommitWithOptions commits the current repository state
func (*Repo) CurrentBranch ¶ added in v0.2.2
CurrentBranch returns the current branch of the repository or an error in case of any failure
func (*Repo) Describe ¶ added in v0.3.0
func (r *Repo) Describe(opts *DescribeOptions) (string, error)
Describe runs `git describe` with the provided arguments
func (*Repo) FetchRemote ¶ added in v0.6.0
FetchRemote gets the objects from the specified remote. It returns true as first argument if something has been fetched remotely.
func (*Repo) HasRemote ¶ added in v0.2.5
HasRemote checks if the provided remote `name` is available and matches the expected `url`
func (*Repo) HasRemoteBranch ¶
HasRemoteBranch takes a branch string and verifies that it exists on the default remote
func (*Repo) HasRemoteTag ¶ added in v0.5.0
HasRemoteTag Checks if the default remote already has a tag
func (*Repo) IsDirty ¶ added in v0.3.2
IsDirty returns true if the worktree status is not clean. It can also error if the worktree status is not retrievable.
func (*Repo) LatestNonPatchFinalToMinor ¶ added in v0.2.1
func (r *Repo) LatestNonPatchFinalToMinor() (DiscoverResult, error)
func (*Repo) LatestPatchToLatest ¶ added in v0.3.0
func (r *Repo) LatestPatchToLatest(branch string) (DiscoverResult, error)
LatestPatchToLatest tries to discover the start (latest v1.x.x]) and end (release-1.x or DefaultBranch) revision inside the repository for the specified release branch.
func (*Repo) LatestPatchToPatch ¶ added in v0.2.1
func (r *Repo) LatestPatchToPatch(branch string) (DiscoverResult, error)
LatestPatchToPatch tries to discover the start (latest v1.x.[x-1]) and end (latest v1.x.x) revision inside the repository for the specified release branch.
func (*Repo) LatestReleaseBranchMergeBaseToLatest ¶ added in v0.2.2
func (r *Repo) LatestReleaseBranchMergeBaseToLatest() (DiscoverResult, error)
LatestReleaseBranchMergeBaseToLatest tries to discover the start (latest v1.x.0 merge base) and end (release-1.(x+1) or DefaultBranch) revision inside the repository.
func (*Repo) LatestTagForBranch ¶ added in v0.2.2
LatestTagForBranch returns the latest available semver tag for a given branch
func (*Repo) LsRemote ¶ added in v0.3.0
LsRemote can be used to run `git ls-remote` with the provided args on the repository
func (*Repo) PreviousTag ¶ added in v0.2.2
PreviousTag tries to find the previous tag for a provided branch and errors on any failure
func (*Repo) Push ¶
Push does push the specified branch to the default remote, but only if the repository is not in dry run mode
func (*Repo) PushToRemote ¶ added in v0.2.5
PushToRemote push the current branch to a spcified remote, but only if the repository is not in dry run mode
func (*Repo) Rebase ¶ added in v0.6.0
Rebase calls rebase on the current repo to the specified branch
func (*Repo) RemoteTags ¶ added in v0.5.0
RemoteTags return the tags that currently exist in the
func (*Repo) Remotes ¶ added in v0.2.5
Remotes lists the currently available remotes for the repository
func (*Repo) RevParse ¶
RevParse parses a git revision and returns a SHA1 on success, otherwise an error.
func (*Repo) RevParseShort ¶
RevParseTagShort parses a git revision and returns a SHA1 trimmed to the length 10 on success, otherwise an error.
func (*Repo) RevParseTag ¶ added in v0.8.0
RevParseTag parses a git revision and returns a SHA1 on success, otherwise an error. If the revision does not match a tag add the remote origin in the revision.
func (*Repo) RevParseTagShort ¶ added in v0.8.0
RevParseTagShort parses a git revision and returns a SHA1 trimmed to the length 10 on success, otherwise an error. If the revision does not match a tag add the remote origin in the revision.
func (*Repo) SetDry ¶
func (r *Repo) SetDry()
Set the repo into dry run mode, which does not modify any remote locations at all.
func (*Repo) SetInnerRepo ¶ added in v0.2.2
func (r *Repo) SetInnerRepo(repo Repository)
SetInnerRepo can be used to manually set the inner repository
func (*Repo) SetMaxRetries ¶ added in v0.5.0
SetMaxRetries defines the number of times, the git client will retry some operations when timing out or network failures. Setting it to 0 disables retrying
func (*Repo) SetWorktree ¶ added in v0.2.2
SetWorktree can be used to manually set the repository worktree
func (*Repo) ShowLastCommit ¶ added in v0.6.0
ShowLastCommit is a simple function that runs git show and returns the last commit in the log
func (*Repo) Status ¶ added in v0.6.0
Status reads and returns the Status object from the repository
func (*Repo) Tag ¶ added in v0.6.0
Tag creates a new annotated tag for the provided `name` and `message`.
func (*Repo) TagsForBranch ¶ added in v0.2.2
TagsForBranch returns a list of tags for the provided branch sorted by creation date
func (*Repo) UserCommit ¶ added in v0.2.7
UserCommit makes a commit using the local user's config as well as adding the Signed-off-by line to the commit message
type Repository ¶ added in v0.2.2
type Repository interface { CreateTag(string, plumbing.Hash, *git.CreateTagOptions) (*plumbing.Reference, error) Branches() (storer.ReferenceIter, error) CommitObject(plumbing.Hash) (*object.Commit, error) CreateRemote(*config.RemoteConfig) (*git.Remote, error) DeleteRemote(name string) error Head() (*plumbing.Reference, error) Remote(string) (*git.Remote, error) Remotes() ([]*git.Remote, error) ResolveRevision(plumbing.Revision) (*plumbing.Hash, error) Tags() (storer.ReferenceIter, error) }
Repository is the main interface to the git.Repository functionality