internal/dl: include old unstable release in archive

Updates golang/go#17574
Fixes golang/go#37581
Fixes golang/go#43975

Change-Id: I31cab4b8f8277b3c83ddde001f2649bb5f0bc9c7
Reviewed-on: https://go-review.googlesource.com/c/website/+/290310
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Sean Liao 2021-02-07 20:46:03 +01:00 коммит произвёл Dmitri Shuralyov
Родитель 0466041812
Коммит 97803416bb
2 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -209,13 +209,16 @@ func filesToReleases(fs []File) (stable, unstable, archive []Release) {
}
if !r.Stable {
if len(unstable) != 0 {
// Only show one (latest) unstable version.
// Only show one (latest) unstable version,
// consider the older ones to be archived.
archive = append(archive, *r)
return
}
maj, min, _ := parseVersion(r.Version)
if maj < stableMaj || maj == stableMaj && min <= stableMin {
// Display unstable version only if newer than the
// latest stable release.
// latest stable release, otherwise consider it archived.
archive = append(archive, *r)
return
}
unstable = append(unstable, *r)

Просмотреть файл

@ -94,7 +94,7 @@ func TestFilesToReleases(t *testing.T) {
if got, want := list(unstable), ""; got != want {
t.Errorf("unstable = %q; want %q", got, want)
}
if got, want := list(archive), "go1.7, go1.6, go1.5.2, go1.5"; got != want {
if got, want := list(archive), "go1.7, go1.6, go1.5.2, go1.5, go1.5beta1"; got != want {
t.Errorf("archive = %q; want %q", got, want)
}
}
@ -140,10 +140,13 @@ func TestOldUnstableNotShown(t *testing.T) {
{Version: "go1.7"},
{Version: "go1.7beta1"},
}
_, unstable, _ := filesToReleases(fs)
_, unstable, archive := filesToReleases(fs)
if len(unstable) != 0 {
t.Errorf("got unstable, want none")
}
if got, want := list(archive), "go1.7, go1.7beta1"; got != want {
t.Errorf("archive = %q; want %q", got, want)
}
}
// A new beta should show up under unstable, but not show up under archive. See golang.org/issue/29669.
@ -176,11 +179,14 @@ func TestUnstableShown(t *testing.T) {
{Version: "go1.7"},
{Version: "go1.7beta1"},
}
_, unstable, _ := filesToReleases(fs)
_, unstable, archive := filesToReleases(fs)
// Show RCs ahead of betas.
if got, want := list(unstable), "go1.8rc1"; got != want {
t.Errorf("unstable = %q; want %q", got, want)
}
if got, want := list(archive), "go1.7, go1.8beta2, go1.7beta1"; got != want {
t.Errorf("archive = %q; want %q", got, want)
}
}
// list returns a version list string for the given releases.