git

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 11 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 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 Open

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

Open open the git repo and either clones or fecthes the remote info

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 TagName

type TagName string

func (TagName) TagInLocal

func (b TagName) TagInLocal() plumbing.ReferenceName

func (TagName) TagInRemote

func (b TagName) TagInRemote() plumbing.ReferenceName

Jump to

Keyboard shortcuts

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