Skip to content

Commit

Permalink
cmd/go: fix module replace flag parsed bug
Browse files Browse the repository at this point in the history
In CL 122404, we change -replace syntax from => to =.
And we also need to change this and the tests.

Fixes #26373.

Change-Id: I2d4e85e10c1578540cc7673b93d849270940d776
Reviewed-on: https://go-review.googlesource.com/123778
Reviewed-by: Bryan C. Mills <[email protected]>
Run-TryBot: Bryan C. Mills <[email protected]>
  • Loading branch information
oiooj authored and Bryan C. Mills committed Jul 13, 2018
1 parent 5e60479 commit 00f32fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/modcmd/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func flagReplace(arg string) {
if i = strings.Index(arg, "="); i < 0 {
base.Fatalf("go mod: -replace=%s: need old@v=new[@v] (missing =)", arg)
}
old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+2:])
old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+1:])
if strings.HasPrefix(new, ">") {
base.Fatalf("go mod: -replace=%s: separator between old and new is =, not =>", arg)
}
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/go/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ func TestModEdit(t *testing.T) {
"-droprequire=x.2",
"-exclude=x.1 @ v1.2.0",
"[email protected]",
"[email protected]=>[email protected]",
"[email protected] => ../z",
"[email protected][email protected]",
"[email protected] = ../z",
)
mustHaveGoMod(`module x.x/y/z
Expand Down Expand Up @@ -451,8 +451,8 @@ require x.3 v1.99.0
}

tg.run("mod",
"[email protected]=>y.1/[email protected]",
"[email protected]=>y.1/[email protected]",
"[email protected]=y.1/[email protected]",
"[email protected]=y.1/[email protected]",
)
mustHaveGoMod(`module x.x/y/z
Expand All @@ -466,7 +466,7 @@ replace (
require x.3 v1.99.0
`)
tg.run("mod",
"-replace=x.1=>y.1/[email protected]",
"-replace=x.1=y.1/[email protected]",
)
mustHaveGoMod(`module x.x/y/z
Expand Down

0 comments on commit 00f32fb

Please sign in to comment.