Skip to content

Conversation

@gwatts
Copy link
Contributor

@gwatts gwatts commented May 9, 2025

resolves #73, resolves #186

This is an alternative solution to PR #110 - Downside to this approach is it depends on the module cache behaving a certain way. Upside is it does not require network access to validate URLs (i hit github rate limits with the other approach).

For modules that are not at the root of the repo, Go will make a copy of the LICENSE file from the repo root into the module's directory when creating the .zip file (see https://go.dev/ref/mod#vcs-license)

This throws off URL generation, as FileURL will create a link to a repo URL to the license that doesn't exist as the file was synthesized by Go.

Attempt to detect this case by examining the zip file that Go creates - As it stands, it appends the LICENSE file to the zip's file directory; we can generally assume that if we see such an addition, it's a result of Go copying it there and therefore it's not a real file in the repo, instead being copied from the root.

If we find that to be the case, generate a link to the original LICENSE file at the root of the repo instead.

The complex e2e test here exercises this nicely (updated links didn't work before, now they do).

resolves google#73, resolves google#186

For modules that are not at the root of the repo, Go will make a copy of
the LICENSE file from the repo root into the module's directory when
creating the .zip file (see https://go.dev/ref/mod#vcs-license)

This throws off URL generation, as FileURL will create a link to a repo
URL to the license that doesn't exist as the file was synthesized by Go.

Attempt to detect this case by examining the zip file that Go creates -
As it stands, it appends the LICENSE file to the zip's file directory;
we can generally assume that if we see such an addition, it's a result
of Go copying it there and therefore it's not a real file in the repo,
instead being copied from the root.

If we find that to be the case, generate a link to the original LICENSE
file at the root of the repo instead.

The complex e2e test here exercises this nicely (updated links didn't
work before, now they do).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LICENSE file in repo root is ignored improve robustness of linking to license on hosting website

1 participant