gitutil

package
v1.0.2-pre.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const RepoCacheDirEnv = "KPT_CACHE_DIR"

RepoCacheDirEnv is the name of the environment variable that controls the cache directory for remote repos. Defaults to UserHomeDir/.kpt/repos if unspecified.

Variables

This section is empty.

Functions

func AmendGitExecError

func AmendGitExecError(err error, f func(e *GitExecError))

AmendGitExecError provides a way to amend the GitExecError returned by the GitLocalRunner.run command.

Types

type GitArgKind

type GitArgKind string
const (
	GitArgRef     GitArgKind = "reference"
	GitArgCommit  GitArgKind = "commit"
	GitArgRepoURI GitArgKind = "repo URI"
)

type GitExecError

type GitExecError struct {
	Type    GitExecErrorType
	Args    []string
	Err     error
	Command string
	Repo    string
	Ref     string
	StdErr  string
	StdOut  string
}

GitExecError is an error type returned if kpt encounters an error while executing a git command. It includes information about the command that was executed and the output from git.

func (*GitExecError) Error

func (e *GitExecError) Error() string

type GitExecErrorType

type GitExecErrorType int

GitExecErrorType is used to enumerate git errors.

const (
	// Unknown is used when we can't classify an error into any of the other
	// categories.
	Unknown GitExecErrorType = iota
	// GitExecutableNotFound means the git executable wasn't available.
	GitExecutableNotFound
	// UnknownReference means that provided reference (tag, branch) wasn't
	// found
	UnknownReference
	// HTTPSAuthRequired means we try to access the repo using the https
	// protocol, but the repo required authentication.
	HTTPSAuthRequired
	// RepositoryNotFound means the provided repo uri doesn't seem to point
	// to a valid git repo.
	RepositoryNotFound
	// RepositoryUnavailable means we weren't able to connect to the provided
	// uri.
	RepositoryUnavailable
)

type GitLocalRunner

type GitLocalRunner struct {

	// Dir is the directory the commands are run in.
	Dir string

	// Debug enables output of debug information to stderr.
	Debug bool
	// contains filtered or unexported fields
}

GitLocalRunner runs git commands in a local git repo.

func NewLocalGitRunner

func NewLocalGitRunner(pkg string) (*GitLocalRunner, error)

NewLocalGitRunner returns a new GitLocalRunner for a local package.

func (*GitLocalRunner) Run

func (g *GitLocalRunner) Run(ctx context.Context, command string, args ...string) (RunResult, error)

Run runs a git command. Omit the 'git' part of the command. The first return value contains the output to Stdout and Stderr when running the command.

func (*GitLocalRunner) RunVerbose

func (g *GitLocalRunner) RunVerbose(ctx context.Context, command string, args ...string) (RunResult, error)

RunVerbose runs a git command. Omit the 'git' part of the command. The first return value contains the output to Stdout and Stderr when running the command.

type GitUpstreamRepo

type GitUpstreamRepo interface {
	Uri() string
	Heads() []string
	Tags() []string
	GetFetchedRefs() []string
	GetRepo(ctx context.Context, refs []string) (string, error)
	GetDefaultBranch(ctx context.Context) (string, error)
	ResolveBranch(branch string) (string, bool)
	ResolveTag(tag string) (string, bool)
	ResolveRef(ref string) string
}

func NewGitUpstreamRepo

func NewGitUpstreamRepo(ctx context.Context, uri string) (GitUpstreamRepo, error)

NewGitUpstreamRepo returns a new GitUpstreamRepo for an upstream package.

type RunResult

type RunResult struct {
	Stdout string
	Stderr string
}

Jump to

Keyboard shortcuts

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