moduleversion

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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. 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 (format/README.md, section 2), 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 (R37).

Index

Constants

View Source
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 (format/README.md, sections 7 and 27).

Variables

Rules are the IDs of the rules module-version.*, in the order of section 27.

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.

func SameMajor

func SameMajor(a, b string) (bool, error)

SameMajor says whether two versions of a module are of the same major, as diff reads it and api does when it moves a learner to a newer version of a module (format/README.md, section 27): one X from 1 on, one 0.y for y from 1 on, and each 0.0.z alone.

Types

type Breach added in v0.1.24

type Breach struct {
	Rule    string `json:"rule"`
	Message string `json:"message"`
}

A Breach is a rule of versions that the new version breaks, and why.

func (Breach) String added in v0.1.24

func (b Breach) String() string

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.

func (Change) String

func (c Change) String() string

String writes the change as a line of the report, as a breach of the check of a module is written: the place, then the part, then what changes, as in "server.json #/tasks/apples: minor: the task apples is added".

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 (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. 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 (format/README.md, section 27). 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 of section 2, 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 of section 2 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 (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.

const (
	None Part = iota
	Patch
	Minor
	Major
)

The parts of a version, in their order.

func StepPart

func StepPart(from, to string) (Part, error)

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

func (p Part) MarshalText() ([]byte, error)

MarshalText writes the part by its word, as --json of diff gives it.

func (Part) String

func (p Part) String() string

func (*Part) UnmarshalText

func (p *Part) UnmarshalText(text []byte) error

UnmarshalText reads a part by its word, as MarshalText writes it.

type Published

type Published struct {
	Digest formatv0.Digest
	Files  fs.FS
}

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

type Step struct {
	Version string `json:"version"`
	Part    Part   `json:"part"`
}

A Step is a next version after a version of a module, and the part that the step to it raises.

func Steps

func Steps(version string) ([]Step, error)

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.

Jump to

Keyboard shortcuts

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