Documentation ¶
Index ¶
- Constants
- Variables
- func CheckOnline(ctx context.Context) bool
- func CheckoutRef(repo *git.Repository, refName string) error
- func CloneExisting(_ context.Context, path, _ string) (*git.Repository, error)
- func CloneNonExisting(ctx context.Context, path, url string) (*git.Repository, error)
- func GetHash(repo *git.Repository, refName string) (*plumbing.Hash, error)
- func IsFatalError(err error) bool
- func IsGitRepo(path string) bool
- func IsPartOfGitRepo(path string) (string, bool)
- func IsWarningError(err error) bool
- func NewFatalError(message string) error
- func NewWarningError(message string) error
- func Open(ctx context.Context, path string, url, refName string, progressFn func(string)) (*git.Repository, *object.Commit, error)
- func Open2(ctx context.Context, path, url string) (*git.Repository, error)
- func ResolveToCommit(repo *git.Repository, refName string) (*object.Commit, error)
- type BranchName
- type FatalError
- type TagName
- type WarningError
Constants ¶
const ( //DefaultMainReferenceName plumbing.ReferenceName = "refs/heads/main" OriginName string = "origin" MainBranch BranchName = "main" BranchPrefixInRemoteRepo = "refs/remotes/" + OriginName + "/" BranchPrefixInLocalRepo = "refs/heads/" TagsPrefixInLocalRepo = "refs/tags/" TagsPrefixInRemoteRepo = "refs/tags/" )
Variables ¶
var (
DefaultMainReferenceName plumbing.ReferenceName = plumbing.ReferenceName(BranchPrefixInLocalRepo + "/" + string(MainBranch))
)
Functions ¶
func CheckOnline ¶ added in v0.0.12
func CheckoutRef ¶ added in v0.0.3
CheckoutRef checks out a specific ref
func CloneExisting ¶ added in v0.0.3
func CloneNonExisting ¶ added in v0.0.3
func GetHash ¶ added in v0.0.3
resolveToCommit takes a repository and a reference name (tag or commit hash) and resolves it to a commit object
func IsFatalError ¶ added in v0.0.12
func IsPartOfGitRepo ¶
IsPartOfGitRepo returns the path of the repo and a boolean to indicate if the path is part of a git repo
func IsWarningError ¶ added in v0.0.12
IsWarningError checks if the error is a WarningError.
func NewFatalError ¶ added in v0.0.12
Convenience functions for creating errors
func NewWarningError ¶ added in v0.0.12
func Open ¶
func Open(ctx context.Context, path string, url, refName string, progressFn func(string)) (*git.Repository, *object.Commit, error)
Open open the git repo and either clones or fecthes the remote info
Types ¶
type BranchName ¶
type BranchName string
BranchName represents a relative branch name (i.e. 'main', 'drafts/bucket/v1') and supports transformation to the ReferenceName in local (cached) repository (those references are in the form 'refs/remotes/origin/...') or in the remote repository (those references are in the form 'refs/heads/...').
func (BranchName) BranchInLocal ¶
func (b BranchName) BranchInLocal() plumbing.ReferenceName
func (BranchName) BranchInRemote ¶
func (b BranchName) BranchInRemote() plumbing.ReferenceName
type FatalError ¶ added in v0.0.12
type FatalError struct {
Message string
}
func (*FatalError) Error ¶ added in v0.0.12
func (e *FatalError) Error() string
type TagName ¶
type TagName string
func (TagName) TagInLocal ¶
func (b TagName) TagInLocal() plumbing.ReferenceName
func (TagName) TagInRemote ¶
func (b TagName) TagInRemote() plumbing.ReferenceName
type WarningError ¶ added in v0.0.12
type WarningError struct {
Message string
}
WarningError represents non-critical errors that serve as warnings.
func (*WarningError) Error ¶ added in v0.0.12
func (e *WarningError) Error() string