semver

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Pattern defines the regular expression for matching a semantic version.
	// Taken directly from github.com/Masterminds/semver
	Pattern = `v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?` +
		`(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
		`(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?`

	// Token defines a constant that can be used to perform a string replacement
	// in a consistent manner. Will be replaced with template support in future
	Token = "$VERSION"
)

Variables

View Source
var (
	// Regex for matching a semantic version
	Regex = regexp.MustCompile(Pattern)
)

Functions

func ParsePrerelease added in v1.10.0

func ParsePrerelease(pre string) (string, string, error)

ParsePrerelease attempts to parse a prerelease suffix. Supports a prerelease suffix with and without a leading '-'

Types

type Increment

type Increment string

Increment defines the different types of increment that can be performed against a semantic version

const (
	// NoIncrement represents no increment change to a semantic version
	NoIncrement Increment = "None"
	// PatchIncrement represents a patch increment (1.0.x) to a semantic version
	PatchIncrement Increment = "Patch"
	// MinorIncrement represents a minor increment (1.x.0) to a semantic version
	MinorIncrement Increment = "Minor"
	// MajorIncrement represents a major increment (x.0.0) to a semantic version
	MajorIncrement Increment = "Major"
)

func ParseCommit

func ParseCommit(commit string) Increment

ParseCommit will identify the type of increment to perform by parsing the commit message against the conventional commit standards defined, @see: https://www.conventionalcommits.org/en/v1.0.0/

type Version added in v1.0.0

type Version struct {
	Prefix     string
	Patch      int64
	Minor      int64
	Major      int64
	Prerelease string
	Metadata   string
	Raw        string
}

Version provides a less strict implementation of a semantic version by supporting an optional use of a 'v' prefix

func Parse added in v1.0.0

func Parse(ver string) (Version, error)

Parse a semantic version

func (Version) String added in v1.0.0

func (v Version) String() string

String outputs the unparsed semantic version

Jump to

Keyboard shortcuts

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