versioning

package
v0.0.0-...-e289d49 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MatchGitSSH matches ssh URLs such as 'git@github.com:Southclaws/sampctl'
	MatchGitSSH = regexp.MustCompile(`^([a-zA-Z][a-zA-Z0-9_]+)\@((?:[a-zA-Z][a-zA-Z0-9\-]*\.)*[a-zA-Z][a-zA-Z0-9\-]*)\:((?:[A-Za-z0-9_\-\.]+\/?)*)$`)
	// MatchDependencyString matches a dependency string such as 'Username/Repository:tag', 'Username/Repository@branch', 'Username/Repository#commit'
	MatchDependencyString = regexp.MustCompile(`^\/?([a-zA-Z0-9-]+)\/([a-zA-Z0-9-._]+)(?:\/)?([a-zA-Z0-9-_$\[\]{}().,\/]*)?((?:@)|(?:\:)|(?:#))?(.+)?$`)
)

Functions

func RefFromBranch

func RefFromBranch(repo *git.Repository, meta DependencyMeta) (ref *plumbing.Reference, err error)

RefFromBranch returns a ref from a branch name

func RefFromCommit

func RefFromCommit(repo *git.Repository, meta DependencyMeta) (ref *plumbing.Reference, err error)

RefFromCommit returns a ref from a commit hash

func RefFromTag

func RefFromTag(repo *git.Repository, meta DependencyMeta) (ref *plumbing.Reference, err error)

RefFromTag returns a ref from a given tag

func RefFromTagRef

func RefFromTagRef(repo *git.Repository, pr *plumbing.Reference) (ref *plumbing.Reference, err error)

RefFromTagRef resolves a tag reference to its actual object

Types

type DependencyMeta

type DependencyMeta struct {
	Site   string `json:"site,omitempty"`                           // The site the repo exists on, default is github.com
	User   string `json:"user"`                                     // Repository owner
	Repo   string `json:"repo"`                                     // Repository name
	Path   string `json:"path,omitempty" yaml:"path,omitempty"`     // Optional subdirectory for .inc files
	Tag    string `json:"tag,omitempty" yaml:"tag,omitempty"`       // Target tag
	Branch string `json:"branch,omitempty" yaml:"branch,omitempty"` // Target branch
	Commit string `json:"commit,omitempty" yaml:"commit,omitempty"` // Target commit sha
	SSH    string `json:"ssh,omitempty" yaml:"ssh,omitempty"`       // SSH user (usually 'git')
}

DependencyMeta represents all the individual components of a DependencyString

func (DependencyMeta) CachePath

func (dm DependencyMeta) CachePath(cacheDir string) (path string)

CachePath returns the path from the cache to a cached package

func (DependencyMeta) String

func (dm DependencyMeta) String() string

func (DependencyMeta) URL

func (dm DependencyMeta) URL() string

URL generates a GitHub URL for a package - it does not test the validity of the URL

func (DependencyMeta) Validate

func (dm DependencyMeta) Validate() (err error)

Validate checks for errors in a DependencyMeta object

type DependencyString

type DependencyString string

DependencyString represents a git repository via various patterns

func (DependencyString) Explode

func (d DependencyString) Explode() (dep DependencyMeta, err error)

Explode splits a dependency string into its component parts and returns a meta object a valid pattern is either a git URL or just a user/repo combination followed by an optional versioning string which is either a semantic version number or a SHA1 hash.

Examples of valid dependency strings ignoring versioning:

https://github.com/user/repo
http://github.com/user/repo
github.com/user/repo
user/repo

And, examples of valid dependency strings with the user/repo:version example followed by a description of what the constraint means. (More info: https://github.com/Masterminds/semver#basic-comparisons)

user/repo:1.2.3 (force version 1.2.3)
user/repo:1.2.x (allow any 1.2 build)
user/repo:2.x (allow any version 2 minor)

And finally, examples of dependency strings with additional paths for when include files exist in a subdirectory of the repository.

https://github.com/user/repo/includes:1.2.3
http://github.com/user/repo/includes:1.2.3
github.com/user/repo/includes:1.2.3
user/repo/includes:1.2.3

type VersionedTag

type VersionedTag struct {
	Ref     *plumbing.Reference
	Name    string
	Version *semver.Version
}

VersionedTag represents a git tag ref with a valid semantic version number as a tag

func GetRepoCurrentVersionedTag

func GetRepoCurrentVersionedTag(repo *git.Repository) (tag *VersionedTag, err error)

GetRepoCurrentVersionedTag returns the current versioned tag of a repo if there is one. Otherwise it returns nil.

type VersionedTags

type VersionedTags []VersionedTag

VersionedTags is just for implementing the Sort interface

func GetRepoSemverTags

func GetRepoSemverTags(repo *git.Repository) (versionedTags VersionedTags, err error)

GetRepoSemverTags returns a list of tags that are valid semantic versions

func (VersionedTags) Len

func (c VersionedTags) Len() int

Len returns the length of a collection. The number of Version instances on the slice.

func (VersionedTags) Less

func (c VersionedTags) Less(i, j int) bool

Less is needed for the sort interface to compare two Version objects on the slice. If checks if one is less than the other.

func (VersionedTags) Swap

func (c VersionedTags) Swap(i, j int)

Swap is needed for the sort interface to replace the Version objects at two different positions in the slice.

Jump to

Keyboard shortcuts

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