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>
diff --git a/internal/dl/dl.go b/internal/dl/dl.go
index c7917c7..144d97b 100644
--- a/internal/dl/dl.go
+++ b/internal/dl/dl.go
@@ -209,13 +209,16 @@
}
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)
diff --git a/internal/dl/dl_test.go b/internal/dl/dl_test.go
index eca763e..1744c15 100644
--- a/internal/dl/dl_test.go
+++ b/internal/dl/dl_test.go
@@ -94,7 +94,7 @@
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 @@
{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 @@
{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.