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 table of format/README.md, section 27, and reports every change at its place (R89 spec, R101 spec; R13, R36). 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. The rules module-version.* and the reading of a package of an earlier version of the format by the places every version keeps are not here yet: the epic of code brings them (R16).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 table of format/README.md, section 27: 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 (format/README.md, section 27): 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"`
}
A Comparison is what the comparison of a new version of a module with its published versions gives (format/README.md, section 27): 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. 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 (format/README.md, section 27). It reads each published package by the chain of digests from its digest, modulepackage.ReadParts, 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; otherwise the new version is compared with it by Changes. With no published version, the new one is the first.
The error is for a published package that ReadParts refuses — of an earlier version of the format too, modulepackage.ErrFormatVersion —, one of another module than next, and two of one 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 (format/README.md, section 27): 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 (format/README.md, section 27).
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 (format/README.md, sections 25–27). 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 (format/README.md, section 27). 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.