internal: don't panic on all/all

If CompareBuildContexts sees all/all, it prefers it instead of
panicking.

Change-Id: I50ff46fa2bbad47cfe5539297a08744dd62b261c
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/305969
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
This commit is contained in:
Jonathan Amsterdam 2021-03-30 13:48:50 -04:00
Родитель 5b4814e905
Коммит 362afdf6f9
1 изменённых файлов: 10 добавлений и 4 удалений

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

@ -46,11 +46,17 @@ func CompareBuildContexts(c1, c2 BuildContext) int {
if c1 == c2 {
return 0
}
// We should never see a BuildContext with "all" here.
if c1.GOOS == All || c1.GOARCH == All || c2.GOOS == All || c2.GOARCH == All {
panic("BuildContext with 'all'")
// Although we really shouldn't see a BuildContext with "all" here, we may if the
// DB erroneously has both an all/all row and some other row. So just prefer the all/all.
if c1 == BuildContextAll {
if c2 == BuildContextAll {
return 0
}
return -1
}
if c2 == BuildContextAll {
return 1
}
pos := func(c BuildContext) int {
for i, d := range BuildContexts {
if c == d {