git

package
v0.0.0-...-46caf3d Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package git implements utility routines for operating on remote Git repositories and metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeRepoTags

func NormalizeRepoTags(repoURL string, repoTagsCache RepoTagsCache) (NormalizedTags map[string]NormalizedTag, e error)

NormalizeRepoTags returns a map of normalized tags mapping back to original tags and also commit hashes. An optional repoTagsCache can be supplied to reduce repeated remote connections to the same repo.

func RefBranches

func RefBranches(refs []*plumbing.Reference) (branches []*plumbing.Reference)

Return a list of just the references that are branches.

func RefTags

func RefTags(refs []*plumbing.Reference) (tags []*plumbing.Reference)

Return a list of just the references that are tags.

func RemoteRepoRefsWithRetry

func RemoteRepoRefsWithRetry(repoURL string, retries uint64) (refs []*plumbing.Reference, err error)

RemoteRepoRefsWithRetry will exponentially retry listing the peeled references of the repoURL up to retries times.

func RepoName

func RepoName(repoURL string) (name string, e error)

RepoName returns name of a repo based off the URL for it.

func ValidRepo

func ValidRepo(repoURL string) (valid bool)

Validate the repo by attempting to query it's references.

func ValidRepoAndHasUsableRefs

func ValidRepoAndHasUsableRefs(repoURL string) (valid bool)

Otherwise functional repos that don't have any tags are not valid.

func VersionToCommit

func VersionToCommit(version string, repo string, commitType cves.CommitType, normalizedTags map[string]NormalizedTag) (ac cves.AffectedCommit, e error)

Take an unnormalized version string, a repo, the pre-normalized mapping of tags to commits and return an AffectedCommit.

Types

type NormalizedTag

type NormalizedTag struct {
	OriginalTag string
	Commit      string
}

NormalizedTag holds a normalized (as by NormalizeRepoTags) tag and corresponding commit hash.

type RepoTagsCache

type RepoTagsCache map[string]RepoTagsMap

RepoTags acts as a cache for RepoTags results, keyed on the repo's URL.

type RepoTagsMap

type RepoTagsMap struct {
	Tag           map[string]Tag           // The key is the original tag as seen on the repo.
	NormalizedTag map[string]NormalizedTag // The key is the normalized (as by NormalizeRepoTags) original tag.
}

RepoTagsMap holds all of the tags (naturally occurring and normalized) for a Git repo.

type Tag

type Tag struct {
	Tag    string // Git tag
	Commit string // Git commit hash
}

A GitTag holds a Git tag and corresponding commit hash.

type Tags

type Tags []Tag

func RepoTags

func RepoTags(repoURL string, repoTagsCache RepoTagsCache) (tags Tags, e error)

RepoTags returns an array of Tag being the (unpeeled, if annotated) tags and associated commits in repoURL. An optional repoTagsCache can be supplied to reduce repeated remote connections to the same repo.

func (Tags) Len

func (t Tags) Len() int

func (Tags) Less

func (t Tags) Less(i, j int) bool

func (Tags) Swap

func (t Tags) Swap(i, j int)

Jump to

Keyboard shortcuts

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