aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/buildlist.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-02-22 17:05:32 -0500
committerBryan C. Mills <bcmills@google.com>2021-03-10 21:00:52 +0000
commit2ceb79db526eabff880a8a03caab07258883b216 (patch)
tree576e9a8553b73a555398d9f5aba39b6a69d63ff6 /src/cmd/go/internal/modload/buildlist.go
parentb7f0fb6d9eb9a2c1b2beb9ecd58bdbf3571dd5cd (diff)
downloadgo-2ceb79db526eabff880a8a03caab07258883b216.tar.gz
go-2ceb79db526eabff880a8a03caab07258883b216.zip
cmd/go/internal/modload: make EditBuildList report whether the build list was changed
For #36460 Change-Id: I8dd6e6f998a217a4287212815ce61209df6f007f Reviewed-on: https://go-review.googlesource.com/c/go/+/296609 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/buildlist.go')
-rw-r--r--src/cmd/go/internal/modload/buildlist.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cmd/go/internal/modload/buildlist.go b/src/cmd/go/internal/modload/buildlist.go
index 5de26357e1..3412548efc 100644
--- a/src/cmd/go/internal/modload/buildlist.go
+++ b/src/cmd/go/internal/modload/buildlist.go
@@ -12,6 +12,7 @@ import (
"context"
"fmt"
"os"
+ "reflect"
"strings"
"golang.org/x/mod/module"
@@ -81,12 +82,12 @@ func Selected(path string) (version string) {
// If the versions listed in mustSelect are mutually incompatible (due to one of
// the listed modules requiring a higher version of another), EditBuildList
// returns a *ConstraintError and leaves the build list in its previous state.
-func EditBuildList(ctx context.Context, add, mustSelect []module.Version) error {
+func EditBuildList(ctx context.Context, add, mustSelect []module.Version) (changed bool, err error) {
LoadModFile(ctx)
final, err := editBuildList(ctx, buildList, add, mustSelect)
if err != nil {
- return err
+ return false, err
}
selected := make(map[string]module.Version, len(final))
@@ -106,14 +107,18 @@ func EditBuildList(ctx context.Context, add, mustSelect []module.Version) error
}
if !inconsistent {
- buildList = final
additionalExplicitRequirements = make([]string, 0, len(mustSelect))
for _, m := range mustSelect {
if m.Version != "none" {
additionalExplicitRequirements = append(additionalExplicitRequirements, m.Path)
}
}
- return nil
+ changed := false
+ if !reflect.DeepEqual(buildList, final) {
+ buildList = final
+ changed = true
+ }
+ return changed, nil
}
// We overshot one or more of the modules in mustSelect, which means that
@@ -136,7 +141,7 @@ func EditBuildList(ctx context.Context, add, mustSelect []module.Version) error
m, queue = queue[0], queue[1:]
required, err := reqs.Required(m)
if err != nil {
- return err
+ return false, err
}
for _, r := range required {
if _, ok := reason[r]; !ok {
@@ -164,7 +169,7 @@ func EditBuildList(ctx context.Context, add, mustSelect []module.Version) error
}
}
- return &ConstraintError{
+ return false, &ConstraintError{
Conflicts: conflicts,
}
}