Documentation
¶
Index ¶
- Constants
- Variables
- func CloneRepository(path, url, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions) (*git.Repository, error)
- func GetAuthUrl(url, authType, token string) string
- func GetLatestCommit(repo *git.Repository, ref string) (string, error)
- func UpdateRepository(path, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions) (*git.Repository, error)
- type RefSet
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, proxyOpts transport.ProxyOptions) (*git.Repository, error)
CloneRepository clones a repository from a given URL and reference to a temporary directory
func GetAuthUrl ¶
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, proxyOpts transport.ProxyOptions) (*git.Repository, error)
UpdateRepository updates a local repository by
- fetching the latest changes from the remote
- checking out the specified reference (branch or tag)
- pulling the latest changes from the remote
- 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.
Click to show internal directories.
Click to hide internal directories.