Documentation
¶
Index ¶
- 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 LogConflictWarnings(conflicts []ConflictInfo)
- 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 ConflictInfo
- type Propagator
- type VersionBump
- type VersionDiff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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:
- Start with direct bumps and apply them to result
- Process changed packages in sorted order for deterministic results
- 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)
- When a package receives bumps from multiple paths, keep the higher-priority bump
- 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:
- 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 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:
- Calculate direct bumps from consignments
- Run SCC detection to identify cycles
- Resolve cycle bumps (unify bump types within each SCC)
- 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