-
Notifications
You must be signed in to change notification settings - Fork 505
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
pkg/stash: allow nonsemver requests to be resolved properly #1015
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1015 +/- ##
==========================================
+ Coverage 62.25% 63.18% +0.93%
==========================================
Files 71 71
Lines 2379 2393 +14
==========================================
+ Hits 1481 1512 +31
+ Misses 767 745 -22
- Partials 131 136 +5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If I understood it correctly we will run go mod download
just to get the pseudo version even if we already have the zip/mod/info bits in our storage. I guess there isn't any better way at the moment but it would be great if this mapping functionality would be extracted from go into it's own module at some point.
@marpio Only if the given version is non-semver, which makes sense because on every call to |
👍 I was thinking about a specific commit hash but yes it makes sense for |
@marpio even with commit hashes there are two pieces of information that sort-of require us to clone a repo to find out:
I had always hoped we'd use APIs directly such as GitHub API, Bitbucket's API etc to know this kind of stuff, but oh well :) We can potentially have smart logic to figure a bunch of stuff out, but we really don't need that kinda complexity because all of this is only if a user does the less-usual |
Got it. Thanks for the explanation. |
NOTE: Requires go1.12 beta or above
Fixes #699
GOPROXY=<athens> go get module@master
GET <athens>/module/@v/master.info
go mod download -json module@master
"Version": "v0.0.0-timestamp-sha"
-- the next step is where this PR comes in --
master
) does not equal the version that mod download returnsv0.0.0-timestamp-sha
, then we should check if that new version already exists in our storage or not.v0.0.0-timestamp-sha
exists, then we already have it, just point the download.Protocol to it.v0.0.0-timestamp-sha
does not exist, persist it, then point the download.Protocol to it.Edge cases to contemplate:
What happens when a user asks for
master
but the repo is removed? I think we should error out as this PR does because if a user asks for "master" we assume their intention is to get the latest of an active branch.What happens when a user asks for
<long-commit-sha>
and the repo is removed? I think we should manually resolve the commit sha to a pseudo version and see if it exists. The problem is that pseudo versions carry the latest tag in them so maybe we should ignore that.