ourgit

package
v0.0.0-...-b44964e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitAskPassEnv = "GIT_ASKPASS"
)

Variables

This section is empty.

Functions

func HashesEqual

func HashesEqual(hash1, hash2 string) bool

func HaveShellGit

func HaveShellGit() bool

HaveShellGit checks if "git" command is available.

Types

type CloneOptions

type CloneOptions struct {
	// Path to a local repo which should be used as a reference for a new clone.
	// Equivalent of the --reference CLI flag.
	ReferenceDir string
	// How many commits to fetch. Equivalent of the --depth CLI flag.
	Depth int
	// Head to fetch: it can be a branch name, a tag name, or a hash.
	Ref string
}

type Credentials

type Credentials struct {
	User string
	Pass string
}

type FetchOptions

type FetchOptions struct {
	// How many commits to fetch. Equivalent of the --depth CLI flag.
	Depth    int
	LocalRef string
}

type OurGit

type OurGit interface {
	GetCurrentHash(localDir string) (string, error)
	DoesBranchExist(localDir string, branchName string) (bool, error)
	DoesTagExist(localDir string, tagName string) (bool, error)
	GetToplevelDir(localDir string) (string, error)
	Checkout(localDir string, id string, refType RefType) error
	ResetHard(localDir string) error
	Pull(localDir string, branch string) error
	Fetch(localDir string, what string, opts FetchOptions) error
	IsClean(localDir, version string, excludeGlobs []string) (bool, error)
	Clone(srcURL, localDir string, opts CloneOptions) error
	GetOriginURL(localDir string) (string, error)
}

func NewOurGitGoGit

func NewOurGitGoGit(creds *Credentials) OurGit

NewOurGit returns a go-git-based implementation of OurGit (it doesn't require an external git binary, but is somewhat limited; for example, it doesn't support referenced repositories)

func NewOurGitShell

func NewOurGitShell(creds *Credentials) OurGit

NewOurGit returns a shell-based implementation of OurGit (external git binary is required for that to work)

type RefType

type RefType string
const (
	RefTypeBranch RefType = "branch"
	RefTypeTag    RefType = "tag"
	RefTypeHash   RefType = "hash"
)

Jump to

Keyboard shortcuts

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