git

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOrigin            = "origin"
	DefaultBranch            = "master"
	DefaultPublicKeyAuthUser = "git"
)

Variables

View Source
var HostKeyAlgos []string

HostKeyAlgos holds the HostKey algorithms that the SSH client will advertise to the server. If empty, Go's default is used instead.

View Source
var KexAlgos []string

KexAlgos hosts the key exchange algorithms to be used for SSH connections. If empty, Go's default is used instead.

Functions

func IsConcreteCommit added in v0.25.0

func IsConcreteCommit(c Commit) bool

IsConcreteCommit returns if a given commit is a concrete commit. Concrete commits have most of commit metadata and commit content. In contrast, a partial commit may only have some metadata and no commit content.

Types

type AuthOptions added in v0.17.0

type AuthOptions struct {
	Transport  TransportType
	Host       string
	Username   string
	Password   string
	Identity   []byte
	KnownHosts []byte
	CAFile     []byte
	// TransportOptionsURL is a unique identifier for this set of authentication
	// options. It's used by managed libgit2 transports to uniquely identify
	// which credentials to use for a particular Git operation, and avoid misuse
	// of credentials in a multi-tenant environment.
	// It must be prefixed with a valid transport protocol ("ssh:// "or "http://") because
	// of the way managed transports are registered and invoked.
	// It's a field of AuthOptions despite not providing any kind of authentication
	// info, as it's the only way to sneak it into git.Checkout, without polluting
	// it's args and keeping it generic.
	TransportOptionsURL string
}

AuthOptions are the authentication options for the Transport of communication with a remote origin.

func AuthOptionsFromSecret added in v0.17.0

func AuthOptionsFromSecret(URL string, secret *v1.Secret) (*AuthOptions, error)

AuthOptionsFromSecret constructs an AuthOptions object from the given Secret, and then validates the result. It returns the AuthOptions, or an error.

func AuthOptionsWithoutSecret added in v0.22.0

func AuthOptionsWithoutSecret(URL string) (*AuthOptions, error)

AuthOptionsWithoutSecret constructs a minimal AuthOptions object from the given URL and then validates the result. It returns the AuthOptions, or an error.

func (AuthOptions) Validate added in v0.17.0

func (o AuthOptions) Validate() error

Validate the AuthOptions against the defined Transport.

type CheckoutOptions added in v0.11.0

type CheckoutOptions struct {
	// Branch to checkout, can be combined with Branch with some
	// Implementations.
	Branch string

	// Tag to checkout, takes precedence over Branch.
	Tag string

	// SemVer tag expression to checkout, takes precedence over Tag.
	SemVer string `json:"semver,omitempty"`

	// Commit SHA1 to checkout, takes precedence over Tag and SemVer,
	// can be combined with Branch with some Implementations.
	Commit string

	// RecurseSubmodules defines if submodules should be checked out,
	// not supported by all Implementations.
	RecurseSubmodules bool

	// LastRevision holds the last observed revision of the local repository.
	// It is used to skip clone operations when no changes were detected.
	LastRevision string
}

CheckoutOptions are the options used for a Git checkout.

type CheckoutStrategy

type CheckoutStrategy interface {
	Checkout(ctx context.Context, path, url string, config *AuthOptions) (*Commit, error)
}

type Commit added in v0.8.0

type Commit struct {
	// Hash is the SHA1 hash of the commit.
	Hash Hash
	// Reference is the original reference of the commit, for example:
	// 'refs/tags/foo'.
	Reference string
	// Author is the original author of the commit.
	Author Signature
	// Committer is the one performing the commit, might be different from
	// Author.
	Committer Signature
	// Signature is the PGP signature of the commit.
	Signature string
	// Encoded is the encoded commit, without any signature.
	Encoded []byte
	// Message is the commit message, contains arbitrary text.
	Message string
}

func (*Commit) ShortMessage added in v0.22.0

func (c *Commit) ShortMessage() string

ShortMessage returns the first 50 characters of a commit subject.

func (*Commit) String added in v0.17.0

func (c *Commit) String() string

String returns a string representation of the Commit, composed out the last part of the Reference element, and/or Hash. For example: 'tag-1/a0c14dc8580a23f79bc654faa79c4f62b46c2c22', for a "tag-1" tag.

func (*Commit) Verify added in v0.8.0

func (c *Commit) Verify(keyRing ...string) (string, error)

Verify the Signature of the commit with the given key rings. It returns the fingerprint of the key the signature was verified with, or an error.

type Hash added in v0.17.0

type Hash []byte

func (Hash) String added in v0.17.0

func (h Hash) String() string

String returns the SHA1 Hash as a string.

type Implementation added in v0.17.0

type Implementation string

type Signature added in v0.17.0

type Signature struct {
	Name  string
	Email string
	When  time.Time
}

type TransportType added in v0.17.0

type TransportType string
const (
	SSH   TransportType = "ssh"
	HTTPS TransportType = "https"
	HTTP  TransportType = "http"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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