git_common

package
v0.0.0-...-4ff3f89 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-3-Clause Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Apps will gradually migrate to using MainBranch instead of
	// MasterBranch as more repositories use MainBranch (skbug.com/11842).
	MasterBranch = "master"
	MainBranch   = "main"
	// DefaultRef is the fully-qualified ref name of the default branch for most
	// repositories.
	DefaultRef = RefsHeadsPrefix + MainBranch
	// DefaultRemote is the name of the default remote repository.
	DefaultRemote = "origin"
	// DefaultRemoteBranch is the name of the default branch in the default
	// remote repository, for most repos.
	DefaultRemoteBranch = DefaultRemote + "/" + MainBranch
	// RefsHeadsPrefix is the "refs/heads/" prefix used for branches.
	RefsHeadsPrefix = "refs/heads/"
)

Variables

This section is empty.

Functions

func EnsureGitIsFromCIPD

func EnsureGitIsFromCIPD(ctx context.Context) error

EnsureGitIsFromCIPD returns an error if the version of Git in PATH does not appear to be obtained via CIPD.

func FindGit

func FindGit(ctx context.Context) (string, int, int, error)

FindGit returns the path to the Git executable and the major and minor version numbers, or any error which occurred.

func IsFromCIPD

func IsFromCIPD(git string) bool

IsFromCIPD returns a bool indicating whether or not the given version of Git appears to be obtained via CIPD.

func MocksForFindGit

func MocksForFindGit(ctx context.Context, cmd *exec.Command) error

MocksForFindGit returns a DelegateRun func which can be passed to exec.CommandCollector.SetDelegateRun so that FindGit will succeed when calls to exec are fully mocked out.

func Version

func Version(ctx context.Context, git string) (int, int, error)

Version returns the installed Git version, in the form: (major, minor), or an error if it could not be determined.

func WithGitFinder

func WithGitFinder(ctx context.Context, finder func() (string, error)) context.Context

WithGitFinder overrides how the git_common.FindGit() function locates the git executable. By default, it looks on the PATH, but this can allow other behavior. The primary case is tests, where we load in a hermetic version of git.

Types

This section is empty.

Jump to

Keyboard shortcuts

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