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 HasChangesInSubdir(changedFiles []ChangedFile, subdir string) (bool, error)
- func ResetTrackedFiles(worktree *git.Worktree) error
- func UpdateRepository(path, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions) (*git.Repository, error)
- type ChangedFile
- type RefSet
Constants ¶
const ( RemoteName = "origin" TagPrefix = "refs/tags/" BranchPrefix = "refs/heads/" MainBranch = "refs/heads/main" SwarmModeBranch = "refs/heads/swarm-mode" )
Variables ¶
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
GetLatestCommit retrieves the last commit hash for a given reference in a repository.
func HasChangesInSubdir ¶ added in v0.29.0
func HasChangesInSubdir(changedFiles []ChangedFile, subdir string) (bool, error)
HasChangesInSubdir checks if any of the changed files are in a specified subdirectory.
func ResetTrackedFiles ¶ added in v0.26.1
func ResetTrackedFiles(worktree *git.Worktree) error
ResetTrackedFiles resets all tracked files in the worktree To their last committed state while leaving untracked files intact.
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 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
GetReferenceSet retrieves a RefSet of local and remote references for a given reference name.