version

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidVersion = errors.New("invalid version")

Functions

This section is empty.

Types

type ChangeType

type ChangeType int

ChangeType is the type of change that commit has made in repository.

const (
	// ChangeTypeNone - changes made in commit that doesn't match any
	// of the provided in configuration file version type.
	ChangeTypeNone ChangeType = iota
	// ChangeTypePatch - bump patch version.
	ChangeTypePatch
	// ChangeTypeMinor - bump minor version.
	ChangeTypeMinor
	// ChangeTypeMajor - bump major version.
	ChangeTypeMajor
)

func (*ChangeType) Parse

func (t *ChangeType) Parse(s string)

Parse string into ChangeType.

func (ChangeType) String

func (ct ChangeType) String() (s string)

type Version

type Version struct {
	Prefix string

	Major int
	Minor int
	Patch int

	PreRelease string
	Build      int
}

Version wraps semver library with features related with parsed from commit message change type.

func New

func New(s string) (v *Version, err error)

New returns new instance of version parsed from given string.

func (*Version) Bump

func (v *Version) Bump(change ChangeType)

Bump changes version based on given change type.

func (*Version) BumpMajor

func (v *Version) BumpMajor()

BumpMajor bumps major version.

func (*Version) BumpMinor

func (v *Version) BumpMinor()

BumpMinor bumps minor version.

func (*Version) BumpPatch

func (v *Version) BumpPatch()

BumpPatch bumps patch version.

func (*Version) BumpPreRelease

func (v *Version) BumpPreRelease(change ChangeType, pre string)

BumpPreRelease bumps pre-release build version.

func (*Version) IsGreater

func (v *Version) IsGreater(other *Version) bool

func (*Version) IsPreRelease

func (v *Version) IsPreRelease() bool

IsPreRelease returns true if version has pre-release part.

func (*Version) LatestChangeType

func (v *Version) LatestChangeType() ChangeType

LatestChangeType returns latest change type based on current version.

func (Version) Next

func (v Version) Next(t ChangeType, pre ...string) *Version

Next returns next version depending on given change type. In case of unknown or not versioned change type returned version stays the same.

func (*Version) Revert

func (v *Version) Revert()

Revert changes version to previous one.

func (*Version) String

func (v *Version) String() string

String is a text formatted version name.

Jump to

Keyboard shortcuts

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