]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modload: fix sort condition in (*replacementRepo).Versions
authorBryan C. Mills <bcmills@google.com>
Sat, 17 Oct 2020 01:57:46 +0000 (21:57 -0400)
committerDaniel Martí <mvdan@mvdan.cc>
Sat, 17 Oct 2020 19:22:49 +0000 (19:22 +0000)
commit30119bcca997d154e4ab200b01afa7007b088994
tree590e2718b15f3130444a196ef393dd3697b46cf0
parentc8f6135d4fd0be14bfc63c2bbb911cc9647e00a6
cmd/go/internal/modload: fix sort condition in (*replacementRepo).Versions

In CL 258220 I added replacement versions to the repo versions used in
the modload.Query functions. The versions are computed from a map in
the modfile index, which has a nondeterministic iteration order.

I added a short-circuit condition to skip sorting in the (vastly
common) case where no replacement versions are added. However, while
cleaning up the change I accidentally deleted the line of code that
sets that condition. As a result, the test of that functionality
(mod_get_replaced) has been failing nondeterministically.

This change fixes the condition by comparing the slices before and
after adding versions, rather than by setting a separate variable.
The test now passes reliably (tested with -count=200).

Updates #41577
Updates #41416
Updates #37438
Updates #26241

Change-Id: I49a66a3a5510da00ef42b47f20a168de66100db6
Reviewed-on: https://go-review.googlesource.com/c/go/+/263266
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
src/cmd/go/internal/modload/query.go
src/cmd/go/testdata/script/mod_get_replaced.txt