cmd/go/internal/modcmd: remove the "-add" prefix from "go mod" flags
Change-Id: I71da97cbf623c3612c109b789825b238480c8e97
Reviewed-on: https://go-review.googlesource.com/119320
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/vendor/cmd/go/internal/modcmd/mod.go b/vendor/cmd/go/internal/modcmd/mod.go
index 47facee..d120c27 100644
--- a/vendor/cmd/go/internal/modcmd/mod.go
+++ b/vendor/cmd/go/internal/modcmd/mod.go
@@ -96,7 +96,7 @@
to be semantically consistent. For example, consider this go.mod file:
module M
-
+
require (
A v1
B v1.0.0
@@ -104,7 +104,7 @@
D v1.2.3
E dev
)
-
+
exclude D v1.2.3
First, -fix rewrites non-canonical version identifiers to semver form, so
@@ -172,11 +172,11 @@
CmdMod.Flag.BoolVar(&vgo.CmdModInit, "init", vgo.CmdModInit, "")
CmdMod.Flag.StringVar(&vgo.CmdModModule, "module", vgo.CmdModModule, "")
- CmdMod.Flag.Var(flagFunc(flagAddRequire), "addrequire", "")
+ CmdMod.Flag.Var(flagFunc(flagRequire), "require", "")
CmdMod.Flag.Var(flagFunc(flagDropRequire), "droprequire", "")
- CmdMod.Flag.Var(flagFunc(flagAddExclude), "addexclude", "")
+ CmdMod.Flag.Var(flagFunc(flagExclude), "exclude", "")
CmdMod.Flag.Var(flagFunc(flagDropReplace), "dropreplace", "")
- CmdMod.Flag.Var(flagFunc(flagAddReplace), "addreplace", "")
+ CmdMod.Flag.Var(flagFunc(flagReplace), "replace", "")
CmdMod.Flag.Var(flagFunc(flagDropExclude), "dropexclude", "")
base.AddBuildFlagsNX(&CmdMod.Flag)
@@ -325,12 +325,12 @@
return path
}
-// flagAddRequire implements the -addrequire flag.
-func flagAddRequire(arg string) {
- path, version := parsePathVersion("addrequire", arg)
+// flagRequire implements the -require flag.
+func flagRequire(arg string) {
+ path, version := parsePathVersion("require", arg)
modEdits = append(modEdits, func(f *modfile.File) {
if err := f.AddRequire(path, version); err != nil {
- base.Fatalf("vgo mod: -addrequire=%s: %v", arg, err)
+ base.Fatalf("vgo mod: -require=%s: %v", arg, err)
}
})
}
@@ -345,12 +345,12 @@
})
}
-// flagAddExclude implements the -addexclude flag.
-func flagAddExclude(arg string) {
- path, version := parsePathVersion("addexclude", arg)
+// flagExclude implements the -exclude flag.
+func flagExclude(arg string) {
+ path, version := parsePathVersion("exclude", arg)
modEdits = append(modEdits, func(f *modfile.File) {
if err := f.AddExclude(path, version); err != nil {
- base.Fatalf("vgo mod: -addexclude=%s: %v", arg, err)
+ base.Fatalf("vgo mod: -exclude=%s: %v", arg, err)
}
})
}
@@ -365,42 +365,42 @@
})
}
-// flagAddReplace implements the -addreplace flag.
-func flagAddReplace(arg string) {
+// flagReplace implements the -replace flag.
+func flagReplace(arg string) {
var i int
if i = strings.Index(arg, "=>"); i < 0 {
- base.Fatalf("vgo mod: -addreplace=%s: need old@v=>new[@v] (missing =>)", arg)
+ base.Fatalf("vgo mod: -replace=%s: need old@v=>new[@v] (missing =>)", arg)
}
old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+2:])
if i = strings.Index(old, "@"); i < 0 {
- base.Fatalf("vgo mod: -addreplace=%s: need old@v=>new[@v] (missing @ in old@v)", arg)
+ base.Fatalf("vgo mod: -replace=%s: need old@v=>new[@v] (missing @ in old@v)", arg)
}
oldPath, oldVersion := strings.TrimSpace(old[:i]), strings.TrimSpace(old[i+1:])
if err := module.CheckPath(oldPath); err != nil {
- base.Fatalf("vgo mod: -addreplace=%s: invalid old path: %v", arg, err)
+ base.Fatalf("vgo mod: -replace=%s: invalid old path: %v", arg, err)
}
if modfile.MustQuote(oldVersion) {
- base.Fatalf("vgo mod: -addreplace=%s: invalid old version %q", arg, oldVersion)
+ base.Fatalf("vgo mod: -replace=%s: invalid old version %q", arg, oldVersion)
}
var newPath, newVersion string
if i = strings.Index(new, "@"); i >= 0 {
newPath, newVersion = strings.TrimSpace(new[:i]), strings.TrimSpace(new[i+1:])
if err := module.CheckPath(newPath); err != nil {
- base.Fatalf("vgo mod: -addreplace=%s: invalid new path: %v", arg, err)
+ base.Fatalf("vgo mod: -replace=%s: invalid new path: %v", arg, err)
}
if modfile.MustQuote(newVersion) {
- base.Fatalf("vgo mod: -addreplace=%s: invalid new version %q", arg, newVersion)
+ base.Fatalf("vgo mod: -replace=%s: invalid new version %q", arg, newVersion)
}
} else {
if !modfile.IsDirectoryPath(new) {
- base.Fatalf("vgo mod: -addreplace=%s: unversioned new path must be local directory", arg)
+ base.Fatalf("vgo mod: -replace=%s: unversioned new path must be local directory", arg)
}
newPath = new
}
modEdits = append(modEdits, func(f *modfile.File) {
if err := f.AddReplace(oldPath, oldVersion, newPath, newVersion); err != nil {
- base.Fatalf("vgo mod: -addreplace=%s: %v", arg, err)
+ base.Fatalf("vgo mod: -replace=%s: %v", arg, err)
}
})
}
diff --git a/vendor/cmd/go/vgo_test.go b/vendor/cmd/go/vgo_test.go
index 983ff2e..ce16d29 100644
--- a/vendor/cmd/go/vgo_test.go
+++ b/vendor/cmd/go/vgo_test.go
@@ -121,13 +121,13 @@
tg.run("-vgo", "mod",
"-droprequire=x.1",
- "-addrequire=x.1@v1.0.0",
- "-addrequire=x.2@v1.1.0",
+ "-require=x.1@v1.0.0",
+ "-require=x.2@v1.1.0",
"-droprequire=x.2",
- "-addexclude=x.1 @ v1.2.0",
- "-addexclude=x.1@v1.2.1",
- "-addreplace=x.1@v1.3.0=>y.1@v1.4.0",
- "-addreplace=x.1@v1.4.0 => ../z",
+ "-exclude=x.1 @ v1.2.0",
+ "-exclude=x.1@v1.2.1",
+ "-replace=x.1@v1.3.0=>y.1@v1.4.0",
+ "-replace=x.1@v1.4.0 => ../z",
)
mustHaveGoMod(`module x.x/y/z
@@ -148,7 +148,7 @@
"-droprequire=x.1",
"-dropexclude=x.1@v1.2.1",
"-dropreplace=x.1@v1.3.0",
- "-addrequire=x.3@v1.99.0",
+ "-require=x.3@v1.99.0",
)
mustHaveGoMod(`module x.x/y/z