version

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBump

func ApplyBump(current semver.Version, changeType types.ChangeType) semver.Version

ApplyBump applies a change type bump to a version and returns the new version

func ApplyBumpMap

func ApplyBumpMap(currentVersions map[string]semver.Version, bumps map[string]types.ChangeType) map[string]semver.Version

ApplyBumpMap applies version bumps to a map of packages Returns a new map with updated versions Packages not in the bumps map remain at their current version

func CalculateDirectBumps

func CalculateDirectBumps(consignments []*consignment.Consignment) map[string]string

CalculateDirectBumps calculates the highest priority change type for each package based on consignments. Returns a map of package name to change type string.

When multiple consignments affect the same package, the highest priority change type is selected according to: major > minor > patch

func CalculateNewVersions

func CalculateNewVersions(
	currentVersions map[string]semver.Version,
	directBumps map[string]types.ChangeType,
	propagatedBumps map[string]types.ChangeType,
) map[string]semver.Version

CalculateNewVersions combines direct and propagated bumps, taking the higher of the two Returns a map of package name to new version

func FilterBumpsByPackages

func FilterBumpsByPackages(bumps map[string]types.ChangeType, packages []string) map[string]types.ChangeType

FilterBumpsByPackages filters a bump map to only include specified packages

func GetBumpPriority

func GetBumpPriority(changeType types.ChangeType) int

GetBumpPriority returns a numeric priority for a change type Higher number = higher priority

func GetChangePriority

func GetChangePriority(changeType string) int

GetChangePriority returns the numeric priority of a change type. Higher numbers indicate higher priority. Priority order: major (3) > minor (2) > patch (1) > unknown (0)

func GetPackagesWithBumps

func GetPackagesWithBumps(bumps map[string]types.ChangeType) []string

GetPackagesWithBumps returns a sorted list of package names that have version bumps

func IsHigherPriority

func IsHigherPriority(a, b string) bool

IsHigherPriority returns true if change type a has higher priority than b. Priority order: major > minor > patch

func LogConflictWarnings added in v0.4.0

func LogConflictWarnings(conflicts []ConflictInfo)

LogConflictWarnings logs warnings about detected conflicts using the global logger.

func MaxChangeType

func MaxChangeType(a, b types.ChangeType) types.ChangeType

MaxChangeType returns the higher priority change type Priority order: major > minor > patch

func MergeBumpMaps

func MergeBumpMaps(map1, map2 map[string]types.ChangeType) map[string]types.ChangeType

MergeBumpMaps merges two bump maps, taking the maximum change type for each package If a package exists in both maps, the higher priority change type wins

func PropagateLinked

func PropagateLinked(
	g *graph.DependencyGraph,
	currentVersions map[string]semver.Version,
	directBumps map[string]string,
) (map[string]VersionBump, error)

PropagateLinked propagates version bumps through linked dependencies in the graph. Returns a map of all version bumps (both direct and propagated).

Algorithm:

  1. Start with direct bumps and apply them to result
  2. Process changed packages in sorted order for deterministic results
  3. For each changed package, find packages that depend on it
  4. If dependency has "linked" strategy, propagate the bump (respecting bump mapping)
  5. Skip packages that already have direct bumps (direct takes precedence)
  6. When a package receives bumps from multiple paths, keep the higher-priority bump
  7. Continue until no more changes propagate

func ResolveConflicts

func ResolveConflicts(bumps map[string]VersionBump) map[string]VersionBump

ResolveConflicts resolves conflicting version bump requests for packages. When the same package receives bumps from multiple sources (direct + propagated, or propagated from multiple paths), the higher-priority bump type wins. Detected conflicts are logged as warnings.

Conflict Resolution Policy:

  • Direct bumps always win over propagated bumps
  • Cycle-resolved bumps have already unified all members
  • For propagated bumps from different paths, higher priority wins
  • Warnings are logged when conflicts are detected

func ResolveCycleBumps

func ResolveCycleBumps(
	g *graph.DependencyGraph,
	currentVersions map[string]semver.Version,
	directBumps map[string]string,
) (map[string]VersionBump, error)

ResolveCycleBumps resolves version bumps for packages in cycles (SCCs). When packages form a cycle, all members must receive the same version bump. The highest priority bump among cycle members is selected and applied to all.

Prerequisites: FindStronglyConnectedComponents must be called on the graph first to populate SCC IDs.

Algorithm:

  1. Group packages by their SCC ID
  2. For each SCC with direct bumps: - Find the highest priority bump among members - Apply that bump to ALL members of the SCC
  3. Mark cycle-resolved bumps with source="cycle"
  4. Non-cycle packages keep source="direct"

Types

type ConflictInfo added in v0.4.0

type ConflictInfo struct {
	Package      string   // Package name
	ResolvedType string   // The change type that was applied after resolution
	Sources      []string // Sources that contributed bumps (e.g. "direct", "propagated", "cycle")
}

ConflictInfo records information about a detected conflict for a package.

func ResolveConflictsWithInfo added in v0.4.0

func ResolveConflictsWithInfo(bumps map[string]VersionBump) (map[string]VersionBump, []ConflictInfo)

ResolveConflictsWithInfo resolves conflicts and returns conflict details alongside the result. This is useful for callers who need to inspect or report on detected conflicts.

type Propagator

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

Propagator handles version bump propagation through a dependency graph

func NewPropagator

func NewPropagator(g *graph.DependencyGraph) (*Propagator, error)

NewPropagator creates a new version propagator for the given dependency graph

func (*Propagator) Propagate

func (p *Propagator) Propagate(
	currentVersions map[string]semver.Version,
	consignments []*consignment.Consignment,
) (map[string]VersionBump, error)

Propagate calculates version bumps for all packages based on consignments and dependency relationships. Returns a map of package name to VersionBump.

Algorithm:

  1. Calculate direct bumps from consignments
  2. Run SCC detection to identify cycles
  3. Resolve cycle bumps (unify bump types within each SCC)
  4. Propagate bumps through dependencies (respecting strategies)
  5. Resolve conflicts (multiple sources requesting different bumps)

type VersionBump

type VersionBump struct {
	Package    string         // Package name
	OldVersion semver.Version // Current version
	NewVersion semver.Version // New version after bump
	ChangeType string         // Type of change: "patch", "minor", or "major"
	Source     string         // Source of bump: "direct", "propagated", "cycle"
}

VersionBump represents a version change for a package

type VersionDiff

type VersionDiff struct {
	Package    string
	OldVersion semver.Version
	NewVersion semver.Version
	ChangeType types.ChangeType
}

VersionDiff represents a version change

func CalculateVersionDiffs

func CalculateVersionDiffs(
	currentVersions map[string]semver.Version,
	newVersions map[string]semver.Version,
	bumps map[string]types.ChangeType,
) []VersionDiff

CalculateVersionDiffs computes the differences between current and new versions

Jump to

Keyboard shortcuts

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