Skip to content

Commit 561923f

Browse files
author
Bryan C. Mills
committed
cmd/go/internal/modfetch: skip symlinks in (*coderepo).Zip
Tested manually. Before: $ go mod init golang.org/issue/scratch go: creating new go.mod: module golang.org/issue/scratch $ go1.11.2 mod download github.com/rogpeppe/test2@latest go: finding github.com/rogpeppe/test2 v0.0.11 $ find $GOPATH -name goodbye /tmp/tmp.Y8a8UzX3zD/_gopath/pkg/mod/github.com/rogpeppe/[email protected]/tests/goodbye $ cat $(find $GOPATH -name goodbye) hello After: $ go mod init golang.org/issue/scratch go: creating new go.mod: module golang.org/issue/scratch $ go mod download github.com/rogpeppe/test2@latest go: finding github.com/rogpeppe/test2 v0.0.11 $ find $GOPATH -name goodbye $ find $GOPATH -name hello /tmp/tmp.Zo0jhfLaRs/_gopath/pkg/mod/github.com/rogpeppe/[email protected]/tests/hello A proper regression test would require one of: • a new entry in the vcs-test server (feasible but tedious, and not easily updated by open-source contributors), or • a way to set up an HTTPS proxy in a script_test, or • a way to explicitly populate the module cache from the contents of a local repository (#28835). Fixes #27093 Updates #28835 Change-Id: I72702a7e791f8815965f0f87c82a30df4d6f0151 Reviewed-on: https://go-review.googlesource.com/c/153819 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent c4a8a68 commit 561923f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cmd/go/internal/modfetch/coderepo.go

+5
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ func (r *codeRepo) Zip(dst io.Writer, version string) error {
489489
}
490490

491491
for _, zf := range zr.File {
492+
if !zf.FileInfo().Mode().IsRegular() {
493+
// Skip symlinks (golang.org/issue/27093).
494+
continue
495+
}
496+
492497
if topPrefix == "" {
493498
i := strings.Index(zf.Name, "/")
494499
if i < 0 {

0 commit comments

Comments
 (0)