git

package
v0.21.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteName   = "origin"
	TagPrefix    = "refs/tags/"
	BranchPrefix = "refs/heads/"
	MainBranch   = "refs/heads/main"
)

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
)

Functions

func CloneRepository

func CloneRepository(path, url, ref string, skipTLSVerify bool) (*git.Repository, error)

CloneRepository clones a repository from a given URL and reference to a temporary directory

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 UpdateRepository added in v0.16.0

func UpdateRepository(path, ref string, skipTLSVerify bool) (*git.Repository, error)

UpdateRepository updates a local repository by

  1. fetching the latest changes from the remote
  2. checking out the specified reference (branch or tag)
  3. pulling the latest changes from the remote
  4. returning the updated repository

Allowed reference forma

  • Branches: refs/heads/main or main
  • Tags: refs/tags/v1.0.0 or v1.0.0

Types

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.

Jump to

Keyboard shortcuts

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