parser

package
v0.0.0-...-34efa27 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unreleased tag is defined in keepachangelog 1.0.0.
	// https://keepachangelog.com/en/1.0.0/
	Unreleased = "[Unreleased]"
)

Variables

This section is empty.

Functions

func CastVersion

func CastVersion(name, val string) (int, error)

CastVersion parse and set a string into given struct.

func Latest

func Latest(doc string) (string, error)

Latest returns the latest version stored in document. This operation simply matches to the first h2 header.

func LatestAny

func LatestAny(doc string) (string, error)

LatestAny returns the latest [version] stored in document. Unlike `Latest` which follows Semantic Versioning, this function parse arbitary string excluding `## [Unreleased]` and string with blank spaces. This operation simply matches to the first h2 header.

func Show

func Show(doc string, ver string) ([]string, error)

Show returns changes of given version.

func To

func To(doc string, ver string) (string, error)

To returns document replaced with given version.

func Version

func Version(in string) (string, error)

Version transforms 0.1.0 to [0.1.0]. Returns error when given input is not following SemVar.

Types

type SemanticVersion

type SemanticVersion struct {
	Major int
	Minor int
	Patch int
}

SemanticVersion represents major/minor/patch numbers.

func NewSemanticVersion

func NewSemanticVersion(given string) (*SemanticVersion, error)

NewSemanticVersion takes arbitary string, parse and return struct.

func SortVersions

func SortVersions(in []SemanticVersion) []SemanticVersion

SortVersions in ascending order with dumb algorithm.

func (SemanticVersion) Increment

Increment version according to given type. The type must be one of Major/Minor/Patch.

Given 1.2.3 as example: - Increment(Major) --> 2.2.3 - Increment(Minor) --> 1.3.3 - Increment(Patch) --> 1.2.4

func (SemanticVersion) IsEqual

func (c SemanticVersion) IsEqual(in *SemanticVersion) bool

IsEqual compares internal version with given version.

func (SemanticVersion) IsGreater

func (c SemanticVersion) IsGreater(in *SemanticVersion) bool

IsGreater compares internal version with given version.

func (SemanticVersion) String

func (c SemanticVersion) String() string

String decorator.

type VersionType

type VersionType string

VersionType corresponds to Major.Minor.Patch in Semantic Versioning 2.0.0. https://semver.org

const (
	MajorVersion VersionType = "major"
	MinorVersion VersionType = "minor"
	PatchVersion VersionType = "patch"
)

Exposed keys of version types.

func AliasedVersion

func AliasedVersion(in string) (VersionType, error)

AliasedVersion returns the original version type or error. GitFlow idiom is currently available.

func (VersionType) String

func (c VersionType) String() string

String decorator.

Jump to

Keyboard shortcuts

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