calver

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderVersion

func RenderVersion(tokens []Token, v Values) string

RenderVersion formats a version string from tokens and values.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver resolves the next CalVer version from the current date and git tags.

func New

func New(runner port.Runner, cfg *config.Config, now func() time.Time) *Resolver

New constructs a CalVer Resolver. now is injectable for deterministic tests.

func (*Resolver) BumpAuto

func (r *Resolver) BumpAuto(_ []string, _ []string) (string, error)

BumpAuto is not used by the CalVer calculator; it satisfies the VersionCalculator interface for internal/versioning/perenv.

func (*Resolver) BumpFromDate

func (r *Resolver) BumpFromDate(tags []string) (string, error)

BumpFromDate computes the next CalVer version from date only, without querying git. tags is a caller-provided slice of bare version strings (no prefix), newest first. Implements the VersionCalculator interface consumed by internal/versioning/perenv.

func (*Resolver) Resolve

func (r *Resolver) Resolve() (versioning.Result, error)

Resolve returns the next CalVer version result.

type Token

type Token struct {
	Kind    TokenKind
	Literal string // non-empty only when Kind == KindLiteral
}

Token is one component of a parsed CalVer format string.

func ParseFormat

func ParseFormat(format string) ([]Token, error)

ParseFormat parses a CalVer format string (e.g. "YYYY.MM.PATCH") into tokens. Returns an error if PATCH is absent or not the last non-literal token.

type TokenKind

type TokenKind int

TokenKind identifies a CalVer format token.

const (
	KindLiteral TokenKind = iota
	KindYYYY
	KindMM
	KindDD
	KindWW
	KindQQ
	KindSS
	KindSPRINT
	KindPATCH
)

type Values

type Values struct {
	Year, Month, Day, Week, Quarter, Semester, Sprint, Patch int
}

Values holds the numeric components extracted from a CalVer version string.

func ParseVersion

func ParseVersion(tokens []Token, version string) (Values, error)

ParseVersion extracts values from a version string using the given token sequence.

Jump to

Keyboard shortcuts

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