git

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

Functions

func CheckOnline added in v0.0.12

func CheckOnline(ctx context.Context) bool

func CheckoutRef added in v0.0.3

func CheckoutRef(repo *git.Repository, refName string) error

CheckoutRef checks out a specific ref

func CloneExisting added in v0.0.3

func CloneExisting(_ context.Context, path, _ string) (*git.Repository, error)

func CloneNonExisting added in v0.0.3

func CloneNonExisting(ctx context.Context, path, url string) (*git.Repository, error)

func GetHash added in v0.0.3

func GetHash(repo *git.Repository, refName string) (*plumbing.Hash, error)

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 IsFatalError(err error) bool

func IsGitRepo

func IsGitRepo(path string) bool

func IsPartOfGitRepo

func IsPartOfGitRepo(path string) (string, bool)

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

func IsWarningError(err error) bool

IsWarningError checks if the error is a WarningError.

func NewFatalError added in v0.0.12

func NewFatalError(message string) error

Convenience functions for creating errors

func NewWarningError added in v0.0.12

func NewWarningError(message string) error

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

func Open2 added in v0.0.12

func Open2(ctx context.Context, path, url string) (*git.Repository, error)

func ResolveToCommit

func ResolveToCommit(repo *git.Repository, refName string) (*object.Commit, error)

resolveToCommit takes a repository and a reference name (tag or commit hash) and resolves it to a commit object

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

Jump to

Keyboard shortcuts

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