git

package
v0.61.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShortSHALength = 7 // Default length for shortened commit SHAs
	RemoteName            = "origin"
	TagPrefix             = "refs/tags/"
	BranchPrefix          = "refs/heads/"
	MainBranch            = "refs/heads/main"
	SwarmModeBranch       = "refs/heads/swarm-mode"
)

Variables

View Source
var (
	ErrCheckoutFailed             = errors.New("failed to checkout repository")
	ErrFetchFailed                = errors.New("failed to fetch repository")
	ErrPullFailed                 = errors.New("failed to pull repository")
	ErrRepositoryAlreadyExists    = git.ErrRepositoryAlreadyExists
	ErrInvalidReference           = git.ErrInvalidReference
	ErrSSHKeyRequired             = errors.New("ssh URL requires SSH_PRIVATE_KEY to be set")
	ErrPossibleAuthMethodMismatch = errors.New("there might be a mismatch between the authentication method and the repository or submodule remote URL")
)

Functions

func CloneRepository

func CloneRepository(path, url, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions, auth transport.AuthMethod, cloneSubmodules bool) (*git.Repository, error)

CloneRepository clones a repository with HTTP or SSH auth.

func GetAuthUrl

func GetAuthUrl(url, authType, token string) string

GetAuthUrl returns a clone URL with an access token for private repositories.

func GetLatestCommit added in v0.22.0

func GetLatestCommit(repo *git.Repository, ref string) (string, error)

GetLatestCommit retrieves the last commit hash for a given reference in a repository.

func GetShortestUniqueCommitSHA added in v0.55.0

func GetShortestUniqueCommitSHA(repo *git.Repository, commitSHA string, minLength int) (string, error)

GetShortestUniqueCommitSHA returns the shortest unique prefix of a commit SHA in the repository. Similar to the git command `git rev-parse --short=<length> <commitSHA>`.

func HasChangesInSubdir added in v0.29.0

func HasChangesInSubdir(changedFiles []ChangedFile, workingDir, subdir string) (bool, error)

HasChangesInSubdir checks if any of the changed files are in a specified subdirectory.

func HttpTokenAuth added in v0.58.0

func HttpTokenAuth(token string) transport.AuthMethod

HttpTokenAuth returns an AuthMethod for HTTP Basic Auth using a token.

func IsSSH added in v0.57.0

func IsSSH(url string) bool

IsSSH checks if a given URL is an SSH URL.

func ResetTrackedFiles added in v0.26.1

func ResetTrackedFiles(repo *git.Repository) error

ResetTrackedFiles resets all tracked files in the worktree To their last committed state while leaving untracked files intact.

func SSHAuth added in v0.58.0

func SSHAuth(privateKey, keyPassphrase string) (transport.AuthMethod, error)

SSHAuth creates an SSH authentication method using the provided private key.

func UpdateRepository added in v0.16.0

func UpdateRepository(path, url, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions, auth transport.AuthMethod, cloneSubmodules bool) (*git.Repository, error)

UpdateRepository fetches and checks out the requested ref.

Types

type ChangedFile added in v0.29.0

type ChangedFile struct {
	// From represents the file state before the change.
	From diff.File
	// To represents the file state after the change.
	To diff.File
}

ChangedFile represents a file that has changed between two commits.

func GetChangedFilesBetweenCommits added in v0.29.0

func GetChangedFilesBetweenCommits(repo *git.Repository, commitHash1, commitHash2 plumbing.Hash) ([]ChangedFile, error)

GetChangedFilesBetweenCommits retrieves a list of changed files between two commits in a repository.

type RefSet added in v0.22.0

type RefSet struct {
	// contains filtered or unexported fields
}

func GetReferenceSet added in v0.22.0

func GetReferenceSet(repo *git.Repository, ref string) (RefSet, error)

GetReferenceSet retrieves a RefSet of local and remote references for a given reference name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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