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:
@@ -99,6 +99,46 @@ func TestVersions(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Newer", func(t *testing.T) {
|
||||
cases := []struct {
|
||||
release, installed string
|
||||
want bool
|
||||
}{
|
||||
{"v0.4.1", "v0.4.0", true}, {"v0.4.0", "v0.4.0", false}, {"v0.3.9", "v0.4.0", false},
|
||||
{"v0.4.1", "v0.4.0-3-gabc1234", true}, {"v0.4.0", "v0.4.0-3-gabc1234", false},
|
||||
// A commit after v0.4.0 (go get M@main): v0.4.0 and older are
|
||||
// downgrades; v0.4.1 is the next release in Go's order.
|
||||
{"v0.4.0", "v0.4.1-0.20261001120000-abcdef123456", false},
|
||||
{"v0.3.0", "v0.4.1-0.20261001120000-abcdef123456", false},
|
||||
{"v0.4.1", "v0.4.1-0.20261001120000-abcdef123456", true},
|
||||
{"v0.5.0", "v0.4.1-0.20261001120000-abcdef123456", true},
|
||||
// A commit after the pre-release v0.5.0-rc.1.
|
||||
{"v0.4.9", "v0.5.0-rc.1.0.20261001120000-abcdef123456", false},
|
||||
{"v0.5.0", "v0.5.0-rc.1.0.20261001120000-abcdef123456", true},
|
||||
// No tag before the commit, a bare hash, a pre-release, nothing:
|
||||
// never newer.
|
||||
{"v0.1.0", "v0.0.0-20261001120000-abcdef123456", false},
|
||||
{"v9.0.0", "abc1234", false}, {"v9.0.0", "v0.5.0-rc.1", false}, {"v9.0.0", "", false},
|
||||
{"main", "v0.4.0", false}, {"v0.5.0-rc.1", "v0.4.0", false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := Newer(c.release, c.installed); got != c.want {
|
||||
t.Errorf("Newer(%q, %q) = %v, want %v", c.release, c.installed, got, c.want)
|
||||
}
|
||||
}
|
||||
for v, want := range map[string]bool{
|
||||
"v0.4.0": true, "v0.4.0-3-gabc1234": true,
|
||||
"v0.4.1-0.20261001120000-abcdef123456": true,
|
||||
"v0.5.0-rc.1.0.20261001120000-abcdef123456": true,
|
||||
"v0.0.0-20261001120000-abcdef123456": false,
|
||||
"abc1234": false, "v0.5.0-rc.1": false, "": false,
|
||||
} {
|
||||
if got := Comparable(v); got != want {
|
||||
t.Errorf("Comparable(%q) = %v, want %v", v, got, want)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("NewestCompatible", func(t *testing.T) {
|
||||
if _, ok := NewestCompatible(nil, "v0.6.0"); ok {
|
||||
t.Error("nil list found a version")
|
||||
|
||||
Reference in New Issue
Block a user