versionmgr

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package versionmgr manages version updates across multiple file formats. All file paths are from hardcoded GetAllTargets() with no user input. #nosec G304 G306 -- File paths are validated, controlled by tool, and files must be world-readable

Package versionmgr manages atomic version updates with backup/rollback. #nosec G304 G306 -- File paths are from GetAllTargets(), no user input, files must be readable

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteCanonicalVersion

func WriteCanonicalVersion(repoRoot string, version Version) error

WriteCanonicalVersion writes the version to the VERSION file

Types

type DriftReport

type DriftReport struct {
	CanonicalVersion Version
	Files            []FileVersionInfo
	HasDrift         bool
	TotalFiles       int
	FilesInSync      int
	FilesWithDrift   int
	MissingFiles     int
}

DriftReport contains the results of drift detection

func DetectDrift

func DetectDrift(repoRoot string) (*DriftReport, error)

DetectDrift scans all files and compares versions to the VERSION file

func (*DriftReport) ExitCode

func (r *DriftReport) ExitCode() int

ExitCode returns the appropriate exit code for the drift report 0 = no drift, 1 = drift detected

func (*DriftReport) PrintReport

func (r *DriftReport) PrintReport(verbose bool)

PrintReport prints a human-readable drift report

func (*DriftReport) PrintSummary

func (r *DriftReport) PrintSummary()

PrintSummary prints a brief summary without detailed file info

type FileTarget

type FileTarget struct {
	Path        string
	Description string
	UpdateFunc  func(path string, version Version) error
	ExtractFunc func(path string) ([]string, error)
}

FileTarget represents a file that contains version information

func GetAllTargets

func GetAllTargets(repoRoot string) []FileTarget

GetAllTargets returns all files that need version updates

type FileVersionInfo

type FileVersionInfo struct {
	Target         FileTarget
	Exists         bool
	Versions       []string
	ParsedVersions []Version
	InSync         bool
	Error          error
}

FileVersionInfo contains version information for a single file

type UpdateResult

type UpdateResult struct {
	Target  FileTarget
	Success bool
	Error   error
}

UpdateResult contains the result of updating a file

type Updater

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

Updater handles version updates across all files

func NewUpdater

func NewUpdater(repoRoot string, dryRun, verbose bool) *Updater

NewUpdater creates a new Updater

func (*Updater) UpdateAllFiles

func (u *Updater) UpdateAllFiles(version Version) ([]UpdateResult, error)

UpdateAllFiles updates all registered files to the specified version Returns list of results and error if any update fails

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Version represents a semantic version (MAJOR.MINOR.PATCH)

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a semantic version string. Accepts formats: "1.0.1", "v1.0.1", "1.0", "v1.0"

func ReadCanonicalVersion

func ReadCanonicalVersion(repoRoot string) (Version, error)

ReadCanonicalVersion reads the version from the VERSION file

func (Version) BumpMajor

func (v Version) BumpMajor() Version

BumpMajor increments the major version and resets minor and patch to 0

func (Version) BumpMinor

func (v Version) BumpMinor() Version

BumpMinor increments the minor version and resets patch to 0

func (Version) BumpPatch

func (v Version) BumpPatch() Version

BumpPatch increments the patch version

func (Version) Compare

func (v Version) Compare(other Version) int

Compare returns:

-1 if v < other
 0 if v == other
 1 if v > other

func (Version) Equal

func (v Version) Equal(other Version) bool

Equal returns true if versions are equal

func (Version) String

func (v Version) String() string

String returns the version as "MAJOR.MINOR.PATCH" (no 'v' prefix)

func (Version) WithV

func (v Version) WithV() string

WithV returns the version as "vMAJOR.MINOR.PATCH" (with 'v' prefix)

Jump to

Keyboard shortcuts

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