Documentation
¶
Index ¶
- Variables
- func ApplyBump(current semver.Version, changeType types.ChangeType) semver.Version
- func ApplyBumpMap(currentVersions map[string]semver.Version, bumps map[string]types.ChangeType) map[string]semver.Version
- func CalculateDirectBumps(consignments []*consignment.Consignment) map[string]string
- func CalculateNewVersions(currentVersions map[string]semver.Version, ...) map[string]semver.Version
- func FilterBumpsByPackages(bumps map[string]types.ChangeType, packages []string) map[string]types.ChangeType
- func GetBumpPriority(changeType types.ChangeType) int
- func GetChangePriority(changeType string) int
- func GetPackagesWithBumps(bumps map[string]types.ChangeType) []string
- func IsHigherPriority(a, b string) bool
- func MaxChangeType(a, b types.ChangeType) types.ChangeType
- func MergeBumpMaps(map1, map2 map[string]types.ChangeType) map[string]types.ChangeType
- func PropagateLinked(g *graph.DependencyGraph, currentVersions map[string]semver.Version, ...) (map[string]VersionBump, error)
- func ResolveConflicts(bumps map[string]VersionBump) map[string]VersionBump
- func ResolveCycleBumps(g *graph.DependencyGraph, currentVersions map[string]semver.Version, ...) (map[string]VersionBump, error)
- type Propagator
- type VersionBump
- type VersionDiff
Constants ¶
This section is empty.
Variables ¶
var ( // Version is the semantic version of the application Version = "0.1.0" // Commit is the git commit hash Commit = "none" // Date is the build date Date = "unknown" )
Version information for the application These values are typically set at build time via ldflags
Functions ¶
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 ¶
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 ¶
IsHigherPriority returns true if change type a has higher priority than b. Priority order: major > minor > patch
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:
- Start with direct bumps and apply them to result
- For each changed package, find packages that depend on it
- If dependency has "linked" strategy, propagate the bump (respecting bump mapping)
- Skip packages that already have direct bumps (direct takes precedence)
- 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.
In the current implementation, conflicts are prevented by PropagateLinked() which only processes each package once. Direct bumps take precedence over propagated bumps, and the first propagation to reach a package wins.
This function serves as:
- A validation pass to ensure no actual conflicts exist
- A clear extension point for more complex conflict resolution strategies
- Documentation of the conflict resolution policy
Conflict Resolution Policy:
- Direct bumps always win over propagated bumps
- Cycle-resolved bumps have already unified all members
- For propagated bumps, first-to-arrive wins (handled by PropagateLinked)
Future enhancements could include:
- Explicit priority levels for different propagation sources
- User-configurable conflict resolution strategies
- Warnings/errors for detected conflicts requiring manual resolution
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:
- Group packages by their SCC ID
- For each SCC with direct bumps: - Find the highest priority bump among members - Apply that bump to ALL members of the SCC
- Mark cycle-resolved bumps with source="cycle"
- Non-cycle packages keep source="direct"
Types ¶
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:
- Calculate direct bumps from consignments
- Run SCC detection and compress graph
- Topologically sort compressed graph
- Propagate bumps through dependencies (respecting strategies)
- 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