git

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGithubOrg         = "kubernetes"
	DefaultGithubRepo        = "kubernetes"
	DefaultGithubReleaseRepo = "sig-release"
	DefaultGithubURLBase     = "https://github.com"
	DefaultRemote            = "origin"
	DefaultMasterRef         = "HEAD"
	Master                   = "master"
)

Variables

This section is empty.

Functions

func GetDefaultKubernetesRepoURL added in v0.2.5

func GetDefaultKubernetesRepoURL() (string, error)

GetDefaultKubernetesRepoURL returns the default HTTPS repo URL for Kubernetes. Expected: https://github.com/kubernetes/kubernetes

func GetKubernetesRepoURL added in v0.2.5

func GetKubernetesRepoURL(org string, useSSH bool) (string, error)

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

func GetRepoURL(org, repo string, useSSH bool) (string, error)

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 IsReleaseBranch

func IsReleaseBranch(branch string) bool

func Remotify

func Remotify(name string) string

Remotify returns the name prepended with the default remote

Types

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 Remote added in v0.2.5

type Remote struct {
	// contains filtered or unexported fields
}

Remote is a representation of a git remote location

func (*Remote) Name added in v0.2.5

func (r *Remote) Name() string

Name returns the name of the remote

func (*Remote) URLs added in v0.2.5

func (r *Remote) URLs() []string

URLs returns all available URLs of the remote

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Wrapper type for a Kubernetes repository instance

func CloneOrOpenDefaultGitHubRepoSSH

func CloneOrOpenDefaultGitHubRepoSSH(repoPath string) (*Repo, error)

CloneOrOpenDefaultGitHubRepoSSH clones the default Kubernetes GitHub repository via SSH if the repoPath is empty, otherwise updates it at the expected repoPath.

func CloneOrOpenGitHubRepo

func CloneOrOpenGitHubRepo(repoPath, owner, repo string, useSSH bool) (*Repo, error)

CloneOrOpenGitHubRepo creates a temp directory containing the provided GitHub repository via the owner and repo. If useSSH is true, then it will clone the repository using the defaultGithubAuthRoot.

func CloneOrOpenRepo

func CloneOrOpenRepo(repoPath, repoURL string, useSSH bool) (*Repo, error)

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 OpenRepo added in v0.2.3

func OpenRepo(repoPath string) (*Repo, error)

OpenRepo tries to open the provided repoPath

func (*Repo) Add added in v0.2.2

func (r *Repo) Add(filename string) error

Add adds a file to the staging area of the repo

func (*Repo) AddRemote added in v0.2.5

func (r *Repo) AddRemote(name, owner, repo string) error

AddRemote adds a new remote to the current working tree

func (*Repo) Checkout added in v0.2.2

func (r *Repo) Checkout(rev string, args ...string) error

Checkout can be used to checkout any revision inside the repository

func (*Repo) Cleanup

func (r *Repo) Cleanup() error

func (*Repo) Commit added in v0.2.2

func (r *Repo) Commit(msg string) error

Commit commits the current repository state

func (*Repo) CurrentBranch added in v0.2.2

func (r *Repo) CurrentBranch() (branch string, err error)

CurrentBranch returns the current branch of the repository or an error in case of any failure

func (*Repo) DescribeTag

func (r *Repo) DescribeTag(rev string) (string, error)

DescribeTag can be used to retrieve the latest tag for a provided revision

func (*Repo) Dir

func (r *Repo) Dir() string

Dir returns the directory where the repository is stored on disk

func (*Repo) HasRemote added in v0.2.5

func (r *Repo) HasRemote(name, expectedURL string) bool

HasRemote checks if the provided remote `name` is available and matches the expected `url`

func (*Repo) HasRemoteBranch

func (r *Repo) HasRemoteBranch(branch string) error

HasRemoteBranch takes a branch string and verifies that it exists on the default remote

func (*Repo) Head

func (r *Repo) Head() (string, error)

Head retrieves the current repository HEAD as a string

func (*Repo) LatestNonPatchFinalToMinor added in v0.2.1

func (r *Repo) LatestNonPatchFinalToMinor() (DiscoverResult, error)

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 master) revision inside the repository.

func (*Repo) LatestTagForBranch added in v0.2.2

func (r *Repo) LatestTagForBranch(branch string) (tag semver.Version, err error)

LatestTagForBranch returns the latest available semver tag for a given branch

func (*Repo) Merge

func (r *Repo) Merge(from string) error

Merge does a git merge into the current branch from the provided one

func (*Repo) MergeBase

func (r *Repo) MergeBase(from, to string) (string, error)

func (*Repo) PreviousTag added in v0.2.2

func (r *Repo) PreviousTag(tag, branch string) (string, error)

PreviousTag tries to find the previous tag for a provided branch and errors on any failure

func (*Repo) Push

func (r *Repo) Push(remoteBranch string) error

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

func (r *Repo) PushToRemote(remote, remoteBranch string) error

PushToRemote push the current branch to a spcified remote, but only if the repository is not in dry run mode

func (*Repo) Remotes added in v0.2.5

func (r *Repo) Remotes() (res []*Remote, err error)

Remotes lists the currently available remotes for the repository

func (*Repo) RevParse

func (r *Repo) RevParse(rev string) (string, error)

RevParse parses a git revision and returns a SHA1 on success, otherwise an error.

func (*Repo) RevParseShort

func (r *Repo) RevParseShort(rev string) (string, error)

RevParseShort parses a git revision and returns a SHA1 trimmed to the length 10 on success, otherwise an error.

func (*Repo) Rm added in v0.2.2

func (r *Repo) Rm(force bool, files ...string) error

Rm removes files from the repository

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) SetWorktree added in v0.2.2

func (r *Repo) SetWorktree(worktree Worktree)

SetWorktree can be used to manually set the repository worktree

func (*Repo) TagsForBranch added in v0.2.2

func (r *Repo) TagsForBranch(branch string) (res []string, err error)

TagsForBranch returns a list of tags for the provided branch sorted by creation date

type Repository added in v0.2.2

type Repository interface {
	CommitObject(plumbing.Hash) (*object.Commit, error)
	Branches() (storer.ReferenceIter, 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

type Worktree added in v0.2.2

type Worktree interface {
	Add(string) (plumbing.Hash, error)
	Commit(string, *git.CommitOptions) (plumbing.Hash, error)
	Checkout(*git.CheckoutOptions) error
}

Worktree is the main interface to the git.Worktree functionality

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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