mirror of
https://github.com/golang/go
synced 2024-11-24 03:30:18 -07:00
cmd/go: fix bugs in replacement path handling
These are tested in golang.org/cl/357169 and golang.org/cl/358540. Change-Id: I5add3f202db71731487f2688234c547abe1fd287 Reviewed-on: https://go-review.googlesource.com/c/go/+/361416 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
6b223e872a
commit
755ede0c5b
@ -968,7 +968,7 @@ func makeMainModules(ms []module.Version, rootDirs []string, modFiles []*modfile
|
||||
for _, r := range modFiles[i].Replace {
|
||||
if replacedByWorkFile[r.Old.Path] {
|
||||
continue
|
||||
} else if prev, ok := replacements[r.Old]; ok && !curModuleReplaces[r.Old] {
|
||||
} else if prev, ok := replacements[r.Old]; ok && !curModuleReplaces[r.Old] && prev != r.New {
|
||||
base.Fatalf("go: conflicting replacements for %v:\n\t%v\n\t%v\nuse \"go mod editwork -replace %v=[override]\" to resolve", r.Old, prev, r.New, r.Old)
|
||||
}
|
||||
curModuleReplaces[r.Old] = true
|
||||
|
@ -378,7 +378,7 @@ func canonicalizeReplacePath(r module.Version, modRoot string) module.Version {
|
||||
return r
|
||||
}
|
||||
abs := filepath.Join(modRoot, r.Path)
|
||||
if rel, err := filepath.Rel(workFilePath, abs); err == nil {
|
||||
if rel, err := filepath.Rel(filepath.Dir(workFilePath), abs); err == nil {
|
||||
return module.Version{Path: rel, Version: r.Version}
|
||||
}
|
||||
// We couldn't make the version's path relative to the workspace's path,
|
||||
|
Loading…
Reference in New Issue
Block a user