{"modulePath":"github.com/kptdev/kpt","version":"v1.0.0-beta.60","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package gitutil\n\n## Constants\n\n```go\nconst RepoCacheDirEnv = \"KPT_CACHE_DIR\"\n```\nRepoCacheDirEnv is the name of the environment variable that controls the cache directory for remote repos.  Defaults to UserHomeDir/.kpt/repos if unspecified.\n\n## Functions\n\n```go\nfunc AmendGitExecError(err error, f func(e *GitExecError))\n```\nAmendGitExecError provides a way to amend the GitExecError returned by the GitLocalRunner.run command.\n\n## Types\n\n```go\ntype GitExecError struct {\n\tType    GitExecErrorType\n\tArgs    []string\n\tErr     error\n\tCommand string\n\tRepo    string\n\tRef     string\n\tStdErr  string\n\tStdOut  string\n}\n```\nGitExecError 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.\n\n```go\nfunc (e *GitExecError) Error() string\n```\n\n```go\ntype GitExecErrorType int\n```\nGitExecErrorType is used to enumerate git errors.\n\n```go\nconst (\n\t// Unknown is used when we can't classify an error into any of the other\n\t// categories.\n\tUnknown GitExecErrorType = iota\n\t// GitExecutableNotFound means the git executable wasn't available.\n\tGitExecutableNotFound\n\t// UnknownReference means that provided reference (tag, branch) wasn't\n\t// found\n\tUnknownReference\n\t// HTTPSAuthRequired means we try to access the repo using the https\n\t// protocol, but the repo required authentication.\n\tHTTPSAuthRequired\n\t// RepositoryNotFound means the provided repo uri doesn't seem to point\n\t// to a valid git repo.\n\tRepositoryNotFound\n\t// RepositoryUnavailable means we weren't able to connect to the provided\n\t// uri.\n\tRepositoryUnavailable\n)\n```\n\n```go\ntype GitLocalRunner struct {\n\n\t// Dir is the directory the commands are run in.\n\tDir string\n\n\t// Debug enables output of debug information to stderr.\n\tDebug bool\n\t// contains filtered or unexported fields\n}\n```\nGitLocalRunner runs git commands in a local git repo.\n\n```go\nfunc NewLocalGitRunner(pkg string) (*GitLocalRunner, error)\n```\nNewLocalGitRunner returns a new GitLocalRunner for a local package.\n\n```go\nfunc (g *GitLocalRunner) Run(ctx context.Context, command string, args ...string) (RunResult, error)\n```\nRun 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.\n\n```go\nfunc (g *GitLocalRunner) RunVerbose(ctx context.Context, command string, args ...string) (RunResult, error)\n```\nRunVerbose 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.\n\n```go\ntype GitUpstreamRepo struct {\n\tURI string\n\n\t// Heads contains all head refs in the upstream repo as well as the\n\t// each of the are referencing.\n\tHeads map[string]string\n\n\t// Tags contains all tag refs in the upstream repo as well as the\n\t// each of the are referencing.\n\tTags map[string]string\n\t// contains filtered or unexported fields\n}\n```\nGitUpstreamRepo runs git commands in a local git repo.\n\n```go\nfunc NewGitUpstreamRepo(ctx context.Context, uri string, opts ...NewGitUpstreamRepoOption) (*GitUpstreamRepo, error)\n```\nNewGitUpstreamRepo returns a new GitUpstreamRepo for an upstream package.\n\n```go\nfunc (gur *GitUpstreamRepo) GetDefaultBranch(ctx context.Context) (string, error)\n```\nGetDefaultBranch returns the name of the branch pointed to by the HEAD symref. This is the default branch of the repository.\n\n```go\nfunc (gur *GitUpstreamRepo) GetFetchedRefs() []string\n```\n\n```go\nfunc (gur *GitUpstreamRepo) GetRepo(ctx context.Context, refs []string) (string, error)\n```\nGetRepo fetches all the provided refs and the objects. It will fetch it to the cache repo and returns the path to the local git clone in the cache directory.\n\n```go\nfunc (gur *GitUpstreamRepo) ResolveBranch(branch string) (string, bool)\n```\nResolveBranch resolves the branch to a commit SHA. This happens based on the cached information about refs in the upstream repo. If the branch doesn't exist in the upstream repo, the last return value will be false.\n\n```go\nfunc (gur *GitUpstreamRepo) ResolveRef(ref string) (string, bool)\n```\nResolveRef resolves the ref (either tag or branch) to a commit SHA. If the ref doesn't exist in the upstream repo, the last return value will be false.\n\n```go\nfunc (gur *GitUpstreamRepo) ResolveTag(tag string) (string, bool)\n```\nResolveTag resolves the tag to a commit SHA. This happens based on the cached information about refs in the upstream repo. If the tag doesn't exist in the upstream repo, the last return value will be false.\n\n```go\ntype NewGitUpstreamRepoOption func(*GitUpstreamRepo)\n```\n\n```go\nfunc WithFetchedRefs(a map[string]bool) NewGitUpstreamRepoOption\n```\n\n```go\ntype RunResult struct {\n\tStdout string\n\tStderr string\n}\n```\n\n","path":"github.com/kptdev/kpt/pkg/lib/gitutil","name":"gitutil","synopsis":"","isRedistributable":true}
