-
Notifications
You must be signed in to change notification settings - Fork 1k
Interpret strings as branches > semver constraints #715
Conversation
ac944f7
to
6e55120
Compare
This isn't quite ready yet because doesn't work with the testdata from https://gist.github.com/ellotheth/e96f8f2c5fdd1b9e09e183970cfb276b.
|
6e55120
to
f2d0d8c
Compare
f2d0d8c
to
74056c0
Compare
74a0a26
to
62b206f
Compare
@sdboyer This is ready for review, though beware that it is currently pulling into two other PRs, #729 and #744. I recommend limiting the github diff to just the last commit so you don't see the changes from those other PRs. I needed another test case for deduceConstraint where a branch name could be interpreted as a semver. I added that to my deptest fork but let me know if it belongs elsewhere. |
62b206f
to
1570f17
Compare
Rebased now that the other PRs are now merged. |
@sdboyer @darkowlzz @ibrasho Bumping for great glory. 🇺🇸 🎇 |
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.
Naming nits.
cmd/dep/root_analyzer.go
Outdated
// project based on the locked revision and the constraint from the manifest. | ||
// First try matching the revision to a version, then try the constraint from the | ||
// manifest, then finally the revision. | ||
func lookupVersionForLockedProject(pi gps.ProjectIdentifier, c gps.Constraint, rev gps.Revision, sm gps.SourceManager) (version gps.Version, warning error) { |
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.
What's the benefit of named return values here?
Also, naming the error
warning
seems a bit misleading.
For lookupVersionForLockedProject
, it's an error that prevents returning the expected results. Consumers cannot rely on the version returned since it will be nil
.
A consumer can call this value warning
if it doesn't depend on getting a valid gps.Version
value. But I would only call it warning
here if consumers could, somehow, use the returned value if they didn't care about the warning.
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.
I would only call it warning here if consumers could, somehow, use the returned value if they didn't care about the warning.
Thanks! That is a good way of thinking about err/warn, very helpful.
cmd/dep/godep_importer.go
Outdated
warn := errors.Wrapf(err, "Unable to lookup the version represented by %s in %s. Falling back to locking the revision only.", pkg.Rev, pi.ProjectRoot) | ||
g.logger.Printf(warn.Error()) | ||
version = revision | ||
version, warning := lookupVersionForLockedProject(pi, nil, revision, g.sm) |
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.
I'd even call this variable err
since the comment below explains why it was logged and ignored (same thing in glide importer).
I've renamed from warning -> err and removed the named return values. |
I went through it. LGTM 👍 Just wondering why were the files renamed? |
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. 👍
I added a second testdata file, e.g. glide1.lock, then didn't need it later on, but the filename change persisted after I squashed all my commits. Fixing.... 😊 |
|
cmd/dep/root_analyzer_test.go
Outdated
wantV := "v1.0.0" | ||
gotV := v.String() | ||
if gotV != wantV { | ||
t.Fatalf("Expected '%s', got '%s'", wantV, gotV) |
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.
How about adding a little context to the failure message, like we try to do everywhere and in alignment with the existing test in the file?
Same for the tests below 🙂
a1f4e09
to
e6c5754
Compare
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
@darkowlzz Thanks for calling me out on that! 😀 I've added context to the test failure messages and squashed. |
1b181b9
to
b77f0c1
Compare
CLAs look good, thanks! |
Derp, my rebase went awry. All fixed (hopefully). 🤞 |
When a user supplied string in an imported config file, or specified to dep ensure, can be interpreted multiple ways, prefer the branch over a semver constraint. In golang#710, glide.yaml specified v2 for https://github.com/go-mgo/mgo. When we assume that is a semver constraint, solve fails because the hinted revision in the lock (a commit on the v2 branch) doesn't satisfy the assumed constraint of ^2.0.0. The new preferred match order for the user string is: * revision * branch * semver constraint * tag I am giving preference of a semver constraint over a tag so that a bare version, 1.0.0, is interpreted more loosely with an implied caret, ^1.0.0, instead of the stricter exact match.
When selecting a preferred version for a lock (before solve) if the constraint is a semver range, ensure the version selected is compatible.
This seems good to me - can merge once we deal with those conflicts 😄 |
b77f0c1
to
db62987
Compare
I've fixed the merge conflict. |
Fixes #710. When a user supplied string in an imported config file, or specified to
dep ensure
, can be interpreted multiple ways, prefer the branch over a semver constraint.In #710,
glide.yaml
specifiedv2
forhttps://github.com/go-mgo/mgo
. When we assume that is a semver constraint, solve fails because the hinted revision in the lock (a commit on the v2 branch) doesn't satisfy the assumed constraint of^2.0.0
.The new preferred match order for the user string is:
I am giving preference of a semver constraint over a tag so that a bare version,
1.0.0
, is interpreted more loosely with an implied caret,^1.0.0
, instead of the stricter exact match.