fix(34): CR-01 never move a pseudo-version install back to its base release
plugin:update dropped a go.mod require that was not a strict vX.Y.Z and treated it as v0.0.0, so a module at a commit after v0.4.0 (v0.4.1-0.<ts>-<hash>) was moved back to v0.4.0. kiosk.Newer now places a release against a release, a git describe string or a pseudo-version (by the tag it builds on, in Go's version order); plugin:update and the admin Plugins screen badge share it. A pseudo-version with no tag before its commit is left alone with a note naming go get <module>@<tag>.
This commit is contained in:
@@ -45,8 +45,9 @@ type pluginSource struct {
|
||||
// Module is the module providing the package ("" for a package of the
|
||||
// application module).
|
||||
Module string
|
||||
// Version is the module version (module), the base release tag of
|
||||
// git describe (submodule) or "".
|
||||
// Version is the go.mod module version (module: a release or a
|
||||
// pseudo-version, see kiosk.Newer), the base release tag of git
|
||||
// describe (submodule) or "".
|
||||
Version string
|
||||
// Dir is the module root of a submodule or local plugin.
|
||||
Dir string
|
||||
@@ -116,10 +117,9 @@ func installedSource(ctx context.Context, appDir, pkg string) (pluginSource, err
|
||||
apply(gomod.Replace, appDir)
|
||||
apply(work.Replace, workDir)
|
||||
if src.Dir == "" {
|
||||
// The version stays as go.mod has it: a pseudo-version is a commit
|
||||
// after a release, and only kiosk.Newer may compare it (CR-01).
|
||||
src.Kind = ModeModule
|
||||
if !kiosk.ValidVersion(src.Version) {
|
||||
src.Version = ""
|
||||
}
|
||||
return src, nil
|
||||
}
|
||||
if !isOwnRepository(ctx, src.Dir) {
|
||||
@@ -131,6 +131,16 @@ func installedSource(ctx context.Context, appDir, pkg string) (pluginSource, err
|
||||
return src, nil
|
||||
}
|
||||
|
||||
// releaseOrEmpty returns v when it is a vX.Y.Z release and "" otherwise:
|
||||
// a requirement check accepts a version it cannot read (a pseudo-version)
|
||||
// rather than refuse it.
|
||||
func releaseOrEmpty(v string) string {
|
||||
if kiosk.ValidVersion(v) {
|
||||
return v
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// updateStep is one plugin plugin:update moves.
|
||||
type updateStep struct {
|
||||
ID, Package string
|
||||
@@ -279,18 +289,17 @@ func (u *updater) registryReason() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// pick chooses the newest release above have whose framework minimum the
|
||||
// app satisfies, with a note naming a still newer release that needs a
|
||||
// newer framework. When there is none it returns only a note: the newer
|
||||
// release that needs a newer framework, or that have is the newest.
|
||||
// pick chooses the newest release above have (kiosk.Newer: never at or
|
||||
// below the release a pseudo-version or describe string builds on) whose
|
||||
// framework minimum the app satisfies, with a note naming a still newer
|
||||
// release that needs a newer framework. An empty have (a submodule with no
|
||||
// release tag behind its commit) takes any release. When there is none it
|
||||
// returns only a note: the newer release that needs a newer framework, or
|
||||
// that have is the newest.
|
||||
func (u *updater) pick(versions []kiosk.RegistryVersion, have string) (kiosk.RegistryVersion, string) {
|
||||
base := have
|
||||
if base == "" {
|
||||
base = "v0.0.0"
|
||||
}
|
||||
var newer []kiosk.RegistryVersion
|
||||
for _, v := range versions {
|
||||
if kiosk.ValidVersion(v.Version) && kiosk.CompareVersions(v.Version, base) > 0 {
|
||||
if kiosk.ValidVersion(v.Version) && (have == "" || kiosk.Newer(v.Version, have)) {
|
||||
newer = append(newer, v)
|
||||
}
|
||||
}
|
||||
@@ -313,6 +322,12 @@ func (u *updater) planModule(p Plugin, src pluginSource) {
|
||||
u.note(p.ID, "installed as a Go module, and "+why)
|
||||
return
|
||||
}
|
||||
if !kiosk.Comparable(src.Version) {
|
||||
// A commit with no release tag before it, or a pre-release: no
|
||||
// release is known to be newer, and guessing could go back.
|
||||
u.note(p.ID, fmt.Sprintf("installed at %s, which is not after a release; plugin:update does not guess, so pin a release with go get %s@<tag>", displayVersion(src.Version), src.Module))
|
||||
return
|
||||
}
|
||||
versions, err := u.opts.Registry.Versions(u.ctx, p.ID)
|
||||
if errors.Is(err, kiosk.ErrNotFound) {
|
||||
u.note(p.ID, "not in the registry")
|
||||
@@ -421,7 +436,7 @@ func (u *updater) checkRequires(m Manifest, installed map[string]pluginSource) {
|
||||
listed[p.ID] = p.Module
|
||||
}
|
||||
for id, src := range installed {
|
||||
final[id] = src.Version
|
||||
final[id] = releaseOrEmpty(src.Version)
|
||||
}
|
||||
for _, s := range u.steps {
|
||||
final[s.ID] = s.To.Version
|
||||
@@ -439,7 +454,7 @@ func (u *updater) checkRequires(m Manifest, installed map[string]pluginSource) {
|
||||
if !known {
|
||||
src, err := installedSource(u.ctx, u.appDir, listed[dep])
|
||||
if err == nil {
|
||||
have = src.Version
|
||||
have = releaseOrEmpty(src.Version)
|
||||
}
|
||||
}
|
||||
if have != "" && !kiosk.Satisfies(have, min) {
|
||||
|
||||
Reference in New Issue
Block a user