Documentation
¶
Overview ¶
Package moduleversion compares a new version of a module with its published ones: it finds the part of the version that the change asks for, by the format's table of changes and parts, and reports every change at its place. The CLI's diff calls it, and module-registry from stage 4.
Compare reads each published package by the chain of digests, without the files of its device part, and compares the new version with the newest published one: Changes gives the part and the changes of two packages of one module and one version of the format, each row of the table at its place and anything else that differs as a patch. Steps, StepPart and SameMajor give the rule of 0.y.z: the next versions after a version, the part a step raises, and whether two versions are of the same major, as diff and api read it. Compare holds the rules module-version.*, Rules, each a Breach of the Comparison: above against every published version, step against the newest, and the others by the places that every version keeps, so that they hold through a move of the format too; a published package of an earlier version of the format is read by those places alone, and the part of a move is major while the format is v0.
Index ¶
Constants ¶
const ( RuleAbove = "module-version.above" RuleStep = "module-version.step" RuleRetiredComplete = "module-version.retired-complete" RuleRetiredKept = "module-version.retired-kept" RuleRetiredKnown = "module-version.retired-known" RuleIDsKept = "module-version.ids-kept" RuleLanguagesKept = "module-version.languages-kept" RuleBandsKept = "module-version.bands-kept" )
The rules of versions of a module, which refuse a new version rather than a module.
Variables ¶
var Rules = []string{RuleAbove, RuleStep, RuleRetiredComplete, RuleRetiredKept, RuleRetiredKnown, RuleIDsKept, RuleLanguagesKept, RuleBandsKept}
Rules are the IDs of the rules module-version.*, in the order of the refusals of the format's schema of the test vectors of versions.
Functions ¶
func Changes ¶
func Changes(before, after *modulepackage.Package) (Part, []Change, error)
Changes compares two packages of one module and one version of the format — before, the published version, and after, the new one — and gives the part of the version that the comparison finds, the highest that a change raises, and every change, by the format's table of changes and parts: each row of the table at its place, and anything else that differs in the canonical view or in the listing of the device part, but the version, as a patch at each place where the two differ. A difference at or within the place of a change that a row gives is not given again. The changes come in the order of their parts, from the highest, and then of their places.
The error is for two packages of other modules or of other versions of the format, and for a package that is not one modulepackage builds or reads.
Types ¶
type Change ¶
type Change struct {
Part Part `json:"part"`
File string `json:"file"`
Pointer string `json:"pointer"`
Parameters formatv0.Numbers `json:"parameters,omitzero"`
What string `json:"what"`
}
A Change is one change from a published version of a module to a new one, and the part of the version that it raises: where it is — the file of the package, modulepackage.ServerFile for the canonical view and modulepackage.DeviceFile for the listing of the device part, and the place in it as a JSON Pointer in URI fragment form, in the new version, or in the published one for what is gone — the numbers of the parameters of the instance of a template that it is of, and what changes, in words.
type Comparison ¶
type Comparison struct {
Module formatv0.ModuleID `json:"module"`
Version string `json:"version"`
Published []string `json:"published"`
Newest string `json:"newest,omitzero"`
Unchanged bool `json:"unchanged,omitzero"`
Part Part `json:"version_part"`
Next []Step `json:"next_versions,omitzero"`
Raised Part `json:"raised"`
Changes []Change `json:"changes,omitzero"`
Breaches []Breach `json:"breaches,omitzero"`
}
A Comparison is what the comparison of a new version of a module with its published versions gives: the module and the new version, the published versions in the order of Semantic Versioning, and the newest of them, with which the new version is compared. Unchanged says that the new version is the newest published one as it was, and then nothing is compared. Otherwise Part is the part of the version that the comparison finds, Changes every change that it finds, Next the next versions after the newest published one whose step raises a part no lower than Part, and Raised the part that the step to the new version raises, None when it is not the next version after the newest one by one of its parts. Breaches are the rules module-version.* that the new version breaks, in the order the rules are checked: above, step, and then those that read the places every version keeps; a comparison with a breach refuses the new version, and diff exits 1. A first version, with no published one, may be any, and nothing is compared.
func Compare ¶
func Compare(next *modulepackage.Package, published []Published) (*Comparison, error)
Compare compares a new version of a module, its package next, with its published versions. It reads each published package by the chain of digests from its digest — a package of the version of the format that module-kit reads by modulepackage.ReadParts, one of an earlier version by the places that every version keeps — and takes the newest by Semantic Versioning, withdrawn or not. When the new version is that version and its package has that digest, the module has not changed, and nothing is compared. Otherwise the new version is compared with it by Changes, or, when the newest names an earlier version of the format, the part is major while the format is v0; and the rules module-version.* are held: above against every published version, step and retired-kept against the newest, and the others against every one by the places that every version keeps, so through a move of the format too. With no published version, the new one is the first.
The error is for a published package that the chain of digests or the places that every version keeps refuse — of a newer version of the format, modulepackage.ErrFormatVersion, among them —, one of another module than next, and two of one version.
func (*Comparison) Refused ¶ added in v0.1.24
func (c *Comparison) Refused() bool
Refused says whether a rule of versions refuses the new version.
func (*Comparison) String ¶
func (c *Comparison) String() string
String writes the comparison as diff reports it: a line of the module and the versions, then the part found, the next versions and the part raised, and then each change on a line of its own, in the order of Changes.
type Part ¶
type Part int
A Part is a part of a version of a module, as the comparison finds it and a step to the next version raises it, from the lowest: None, when nothing but the version changes; Patch, the same entries, checks and path in other words or pictures; Minor, everything there stays and means the same, and the module gives more or leads otherwise; and Major, something of what a learner had is gone or means something else. It is written by its word, as the test vectors of versions write it.
func StepPart ¶
StepPart gives the part that the step from one version of a module to another raises, or None when to is not the next version after from by one of its parts.
func (Part) MarshalText ¶
MarshalText writes the part by its word, as --json of diff gives it.
func (*Part) UnmarshalText ¶
UnmarshalText reads a part by its word, as MarshalText writes it.
type Published ¶
A Published is a published version of a module: its package as files, without device/, and the digest of the package by which the module index of the newest release names it. A withdrawn version is a published one too.
type Step ¶
A Step is a next version after a version of a module, and the part that the step to it raises.
func Steps ¶
Steps gives the next versions after a version of a module, each by one of its parts, and the part that each step raises, in the order patch, minor and major of the number it raises. From X.Y.Z with X from 1 on, X.Y.(Z+1) is a patch, X.(Y+1).0 a minor and (X+1).0.0 a major. While X is 0, y plays the major, as Cargo reads it: from 0.y.z with y from 1 on, 0.y.(z+1) is a minor, which serves a patch too, and 0.(y+1).0 and 1.0.0 are majors; and from 0.0.z, 0.0.(z+1), 0.1.0 and 1.0.0 are each a major.