Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommitDelimiter      string = "@sha256:"
	PullRequestReference string = "pull/([0-9]+)/head"
	SubPathDelimiter     string = "@subpath:"
)

Variables

This section is empty.

Functions

func CloneRepository

func CloneRepository(
	ctx context.Context,
	gitInfo *GitInfo,
	targetDir string,
	helper string,
	strictHostKeyChecking bool,
	cloneOptions ...Option,
) error

func CloneRepositoryWithEnv

func CloneRepositoryWithEnv(
	ctx context.Context,
	gitInfo *GitInfo,
	extraEnv []string,
	targetDir string,
	helper string,
	strictHostKeyChecking bool,
	cloneOptions ...Option,
) error

func CommandContext

func CommandContext(ctx context.Context, extraEnv []string, args ...string) *exec.Cmd

func GetBranchNameForPR

func GetBranchNameForPR(ref string) string

func GetDefaultExtraEnv

func GetDefaultExtraEnv(strictHostKeyChecking bool) []string

func GetIDForPR

func GetIDForPR(ref string) string

func InstallBinary

func InstallBinary() error

func PingRepository

func PingRepository(str string, extraEnv []string) bool

Types

type CloneStrategy

type CloneStrategy string
const (
	FullCloneStrategy     CloneStrategy = ""
	BloblessCloneStrategy CloneStrategy = "blobless"
	TreelessCloneStrategy CloneStrategy = "treeless"
	ShallowCloneStrategy  CloneStrategy = "shallow"
	BareCloneStrategy     CloneStrategy = "bare"
)

func (*CloneStrategy) Set

func (s *CloneStrategy) Set(v string) error

func (*CloneStrategy) String

func (s *CloneStrategy) String() string

func (*CloneStrategy) Type

func (s *CloneStrategy) Type() string

type Cloner

type Cloner interface {
	Clone(
		ctx context.Context,
		repository string,
		targetDir string,
		extraArgs, extraEnv []string,
	) error
}

func NewCloner

func NewCloner(strategy CloneStrategy) Cloner

func NewClonerWithOpts

func NewClonerWithOpts(options ...Option) Cloner

type GitInfo

type GitInfo struct {
	Repository string
	Branch     string
	Commit     string
	PR         string
	SubPath    string
}

GitInfo is the parsed form of a repository reference. Branch, Commit, PR, and SubPath are independent: a reference can carry zero or more of them. PR is exclusive with Branch and Commit.

func NormalizeRepository

func NormalizeRepository(str string) *GitInfo

NormalizeRepository parses a repository reference into its structured parts. Accepts plain URLs, the "git:<url>" workspace-source scheme, and references suffixed with @branch, @subpath:<path>, @sha256:<commit>, or @pull/N/head. Bare host[/path] inputs are upgraded to https://.

type Option

type Option func(*cloner)

func WithCloneStrategy

func WithCloneStrategy(strategy CloneStrategy) Option

func WithRecursiveSubmodules

func WithRecursiveSubmodules() Option

func WithSkipLFS

func WithSkipLFS() Option

Jump to

Keyboard shortcuts

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