Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mod/zip: CreateFromVCS doesn't include LICENSE from repo root, does not match modfetch, results in miscomputed go.sum #60442

Closed
liggitt opened this issue May 25, 2023 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@liggitt
Copy link
Contributor

liggitt commented May 25, 2023

What version of Go are you using (go version)?

go1.20

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

darwin/arm64

What did you do?

Used https://pkg.go.dev/golang.org/x/mod@v0.10.0/zip#CreateFromVCS to create a zip file for a submodule to populate a file://-based goproxy directory.

The root of the repo contains a LICENSE file. The subdirectory for the submodule did not.

The produced zip file did not include the LICENSE file from the repo root. This differed from the zip file downloaded by modfetch once the revision was published, and meant the go.sum calculated pre-publish did not match.

The need to copy the LICENSE file from the repo root if the subdirectory did not contain a license was mentioned during review of the CreateFromVCS addition in https://go-review.googlesource.com/c/mod/+/330769:

Note that we also may need to copy the LICENSE file from the repository root, even if it's not in the module subdirectory.

So basically I think CreateFromVCS needs to:

  • Given the repository root directory, detect the VCS tool in use.
  • Extract code from cmd/go/internal/modfetch/codehost to run 'git archive' or something similar, writing to a temporary archive.
  • Extract code from cmd/go/internal/modfetch.codeRepo.Zip to produce the correct list of Files. Maybe add LICENSE.

It doesn't look like that logic made it into the final version.

@gopherbot gopherbot added this to the Unreleased milestone May 25, 2023
@liggitt
Copy link
Contributor Author

liggitt commented May 25, 2023

cc @codyoss @quartzmo

@liggitt liggitt changed the title x/mod/zip: CreateFromVCS doesn't include LICENSE from repo root, does not match go mod fetch behavior x/mod/zip: CreateFromVCS doesn't include LICENSE from repo root, does not match modfetch, results in miscomputed go.sum May 25, 2023
@gopherbot
Copy link

Change https://go.dev/cl/498935 mentions this issue: zip: fix LICENSE file handling to match modfetch

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants