git

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: May 9, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//DefaultMainReferenceName plumbing.ReferenceName = "refs/heads/main"
	OriginName string     = "origin"
	MainBranch BranchName = "main"

	BranchPrefixInRemoteRepo = "refs/remotes/" + OriginName + "/"
	BranchPrefixInLocalRepo  = "refs/heads/"
	TagsPrefixInLocalRepo    = "refs/tags/"
	TagsPrefixInRemoteRepo   = "refs/tags/"
)

Variables

Functions

This section is empty.

Types

type BranchName added in v0.0.47

type BranchName string

BranchName represents a relative branch name (i.e. 'main', 'drafts/bucket/v1') and supports transformation to the ReferenceName in local (cached) repository (those references are in the form 'refs/remotes/origin/...') or in the remote repository (those references are in the form 'refs/heads/...').

func (BranchName) BranchInLocal added in v0.0.47

func (b BranchName) BranchInLocal() plumbing.ReferenceName

func (BranchName) BranchInRemote added in v0.0.47

func (b BranchName) BranchInRemote() plumbing.ReferenceName

type Git

type Git interface {
	// Clone takes the given GitRepo reference and clones the repo
	// with its internal implementation.
	Clone(ctx context.Context) error
}

type GitRepo

type GitRepo interface {
	GetName() string
	GetCloneURL() *url.URL
	GetBranch() string
	GetLocalPath() string
	GetTag() string
	SetTag(string)
	SetBranch(string)
	SetLocalPath(string)
}

func NewRepo

func NewRepo(urlPath string) (GitRepo, error)

NewRepo parses the given git urlPath and returns an interface that is backed by Github or Gitlab repo implementations.

type GitRepoStruct

type GitRepoStruct struct {
	// CloneURL is the URL that will be used for cloning the repo
	CloneURL       *url.URL
	RepositoryName string
	// GitBranch is the referenced Git branch name.
	GitBranch string
	// Tag name - either tag or branch should be set.
	Tag           string
	LocalRepoPath string
}

GitRepoStruct is a struct that contains all the fields required for a GitRepo instance.

func (*GitRepoStruct) GetBranch

func (u *GitRepoStruct) GetBranch() string

GetBranch returns the referenced Git branch name. the empty string is returned otherwise.

func (*GitRepoStruct) GetCloneURL

func (u *GitRepoStruct) GetCloneURL() *url.URL

GetCloneURL returns the CloneURL of the repository.

func (*GitRepoStruct) GetLocalPath

func (u *GitRepoStruct) GetLocalPath() string

func (*GitRepoStruct) GetName

func (u *GitRepoStruct) GetName() string

GetName returns the repository name.

func (*GitRepoStruct) GetTag

func (u *GitRepoStruct) GetTag() string

func (*GitRepoStruct) SetBranch

func (u *GitRepoStruct) SetBranch(b string)

func (*GitRepoStruct) SetLocalPath

func (u *GitRepoStruct) SetLocalPath(p string)

func (*GitRepoStruct) SetTag

func (u *GitRepoStruct) SetTag(t string)

type GoGit

type GoGit struct {
	ProxyURL *url.URL
	// contains filtered or unexported fields
}

func NewGoGit

func NewGoGit(gitRepo GitRepo, secret types.NamespacedName, credentialResolver auth.CredentialResolver) *GoGit

func (*GoGit) CheckoutCommit added in v0.0.47

func (g *GoGit) CheckoutCommit(ctx context.Context, commitHash string) error

func (*GoGit) Clone

func (g *GoGit) Clone(ctx context.Context) error

Clone takes the given GitRepo reference and clones the repo with its internal implementation.

func (*GoGit) EnsureCommit added in v0.0.47

func (g *GoGit) EnsureCommit(ctx context.Context, commitHash string) (string, error)

func (*GoGit) SetProxy added in v0.0.30

func (g *GoGit) SetProxy(p string) error

type TagName added in v0.0.47

type TagName string

func (TagName) TagInLocal added in v0.0.47

func (b TagName) TagInLocal() plumbing.ReferenceName

func (TagName) TagInRemote added in v0.0.47

func (b TagName) TagInRemote() plumbing.ReferenceName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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