gitutil

package
v0.39.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 10 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

View Source
var DefaultRef = func(repo string) (string, error) {
	masterRef := "master"
	mainRef := "main"
	masterExists, err := branchExists(repo, masterRef)
	if err != nil {
		return "", err
	}
	mainExists, err := branchExists(repo, mainRef)
	if err != nil {
		return "", err
	}
	if masterExists {
		return masterRef, nil
	} else if mainExists {
		return mainRef, nil
	}
	return masterRef, nil
}

DefaultRef returns the DefaultRef to "master" if master branch exists in remote repository, falls back to "main" if master branch doesn't exist Making it a var so that it can be overridden for local testing

Functions

This section is empty.

Types

type GitRunner

type GitRunner struct {
	// Dir is the directory the commands are run in.
	Dir string

	// RepoDir is the directory of the git repo containing the package
	RepoDir string

	// Stderr is where the git command Stderr is written
	Stderr *bytes.Buffer

	// Stdin is where the git command Stdin is read from
	Stdin *bytes.Buffer

	// Stdout is where the git command Stdout is written
	Stdout *bytes.Buffer

	// Verbose prints verbose command information
	Verbose bool
}

GitRunner runs git commands in a git repo.

func NewLocalGitRunner

func NewLocalGitRunner(pkg string) *GitRunner

NewLocalGitRunner returns a new GitRunner for a local package.

func NewUpstreamGitRunner

func NewUpstreamGitRunner(uri, dir string, required []string, optional []string) (*GitRunner, error)

NewUpstreamGitRunner returns a new GitRunner for an upstream package.

The upstream package repo will be fetched to a local cache directory under $HOME/.kpt and hard reset to origin/main. The refs will also be fetched so they are available locally.

func (*GitRunner) Run

func (g *GitRunner) Run(args ...string) error

Run runs a git command. Omit the 'git' part of the command.

Jump to

Keyboard shortcuts

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