Skip to content

Commit

Permalink
vend: Correctly copy replaced modules to their replacement directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
c00w committed Jul 29, 2020
1 parent dc956fa commit 24fdebf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 9 additions & 1 deletion file/file.go
Expand Up @@ -34,7 +34,7 @@ dep:
}

// CopyModuleDependencies copies module level dependencies transitively.
func CopyModuleDependencies(deps []Dep) {
func CopyModuleDependencies(mod GoMod, deps []Dep) {
modFile := cli.ReadModFile(vendorDir())
deleteVendorDir()

Expand All @@ -44,6 +44,14 @@ func CopyModuleDependencies(deps []Dep) {
copy(d.Dir, dest)
}

for _, d := range mod.Replace {
if d.Old.Path != d.New.Path {
src := path.Join(vendorDir(), d.New.Path)
dest := path.Join(vendorDir(), d.Old.Path)
copy(src, dest)
}
}

SaveReport(modFile)
}

Expand Down
8 changes: 3 additions & 5 deletions main.go
Expand Up @@ -16,15 +16,13 @@ func main() {
cli.UpdateModule()
json := cli.ReadDownloadJSON()
deps := file.ParseDownloadJSON(json)
json = cli.ReadModJSON()
mod := file.ParseModJSON(json)

if options.PkgOnly {
json = cli.ReadModJSON()
mod := file.ParseModJSON(json)

file.CopyPkgDependencies(mod, deps)
} else {

file.CopyModuleDependencies(deps)
file.CopyModuleDependencies(mod, deps)
}
}
}

0 comments on commit 24fdebf

Please sign in to comment.