git

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRepoHTTPClient

func GetRepoHTTPClient(repoURL string, insecure bool, creds Creds) *http.Client

Returns a HTTP client object suitable for go-git to use using the following pattern:

  • If insecure is true, always returns a client with certificate verification turned off.
  • If one or more custom certificates are stored for the repository, returns a client with those certificates in the list of root CAs used to verify the server's certificate.
  • Otherwise (and on non-fatal errors), a default HTTP client is returned.

func IsCommitSHA

func IsCommitSHA(sha string) bool

IsCommitSHA returns whether or not a string is a 40 character SHA-1

func IsHTTPSURL

func IsHTTPSURL(url string) bool

IsHTTPSURL returns true if supplied URL is HTTPS URL

func IsSSHURL

func IsSSHURL(url string) (bool, string)

IsSSHURL returns true if supplied URL is SSH URL

func IsTruncatedCommitSHA

func IsTruncatedCommitSHA(sha string) bool

IsTruncatedCommitSHA returns whether or not a string is a truncated SHA-1

func NormalizeGitURL

func NormalizeGitURL(repo string) string

NormalizeGitURL normalizes a git URL for purposes of comparison, as well as preventing redundant local clones (by normalizing various forms of a URL to a consistent location). Prefer using SameURL() over this function when possible. This algorithm may change over time and should not be considered stable from release to release

func SameURL

func SameURL(leftRepo, rightRepo string) bool

SameURL returns whether or not the two repository URLs are equivalent in location

func TestRepo

func TestRepo(repo string, creds Creds, insecure bool, enableLfs bool) error

TestRepo tests if a repo exists and is accessible with the given credentials

Types

type Client

type Client interface {
	Root() string
	Init() error
	Fetch() error
	FetchRef(ref string) error
	Checkout(revision string) error
	LsRefs() (*Refs, error)
	LsRemote(revision string) (string, error)
	LsFiles(path string) ([]string, error)
	LsLargeFiles() ([]string, error)
	CommitSHA() (string, error)
	RevisionMetadata(revision string) (*RevisionMetadata, error)
	VerifyCommitSignature(string) (string, error)
	Branch(sourceBranch, targetBranch string) error
	Commit(pathSpec string, message string, signingKey string) error
	Push(remote string, branch string, force bool) error
	Add(path string) error
	SymRefToBranch(symRef string) (string, error)
	Config(username string, email string) error
}

Client is a generic git client interface

func NewClient

func NewClient(rawRepoURL string, creds Creds, insecure bool, enableLfs bool) (Client, error)

func NewClientExt

func NewClientExt(rawRepoURL string, root string, creds Creds, insecure bool, enableLfs bool) (Client, error)

type Creds

type Creds interface {
	Environ() (io.Closer, []string, error)
}

type HTTPSCreds

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

HTTPS creds implementation

func NewHTTPSCreds

func NewHTTPSCreds(username string, password string, clientCertData string, clientCertKey string, insecure bool) HTTPSCreds

func (HTTPSCreds) Environ

func (c HTTPSCreds) Environ() (io.Closer, []string, error)

Get additional required environment variables for executing git client to access specific repository via HTTPS.

type NopCloser

type NopCloser struct {
}

nop implementation

func (NopCloser) Close

func (c NopCloser) Close() error

type NopCreds

type NopCreds struct {
}

func (NopCreds) Environ

func (c NopCreds) Environ() (io.Closer, []string, error)

type Refs

type Refs struct {
	Branches []string
	Tags     []string
}

this should match reposerver/repository/repository.proto/RefsList

type RevisionMetadata

type RevisionMetadata struct {
	Author  string
	Date    time.Time
	Tags    []string
	Message string
}

type SSHCreds

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

SSH implementation

func NewSSHCreds

func NewSSHCreds(sshPrivateKey string, caPath string, insecureIgnoreHostKey bool) SSHCreds

func (SSHCreds) Environ

func (c SSHCreds) Environ() (io.Closer, []string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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