This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Assume an implied caret when a semver doesn't have an explicit constraint #631
Merged
+121
−22
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a75d6d2
Support implied carets in gps
carolynvs ecf43b9
Always use implied carets in dep
carolynvs 5285e62
Preserve previous test behavior before implied caret
carolynvs 8dcaab5
Fix deduceConstraint test to not rely upon the types being comparable
carolynvs 16e350f
Update testdata now that init omits carets in the manifest
carolynvs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,4 @@ | |
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptest" | ||
version = "^1.0.0" | ||
version = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,4 @@ | |
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptest" | ||
version = "^1.0.0" | ||
version = "1.0.0" |
2 changes: 1 addition & 1 deletion
2
cmd/dep/testdata/harness_tests/ensure/override/case1/testcase.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"commands": [ | ||
["init"], | ||
["ensure", "-override", "github.com/sdboyer/[email protected]"] | ||
["ensure", "-override", "github.com/sdboyer/deptest@=1.0.0"] | ||
], | ||
"error-expected": "", | ||
"vendor-final": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptest" | ||
version = "^0.8.0" | ||
version = "0.8.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptest" | ||
version = "^0.8.0" | ||
version = "0.8.0" | ||
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptestdos" | ||
version = "^2.0.0" | ||
version = "2.0.0" |
2 changes: 1 addition & 1 deletion
2
cmd/dep/testdata/harness_tests/init/skip-hidden/final/Gopkg.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
[[dependencies]] | ||
name = "github.com/sdboyer/deptest" | ||
version = "^1.0.0" | ||
version = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,14 @@ var ( | |
type Constraint interface { | ||
fmt.Stringer | ||
|
||
// ImpliedCaretString converts the Constraint to a string in the same manner | ||
// as String(), but treats the empty operator as equivalent to ^, rather | ||
// than =. | ||
// | ||
// In the same way that String() is the inverse of NewConstraint(), this | ||
// method is the inverse of to NewSemverConstraintIC(). | ||
ImpliedCaretString() string | ||
|
||
// Matches indicates if the provided Version is allowed by the Constraint. | ||
Matches(Version) bool | ||
|
||
|
@@ -64,6 +72,24 @@ func NewSemverConstraint(body string) (Constraint, error) { | |
return semverConstraint{c: c}, nil | ||
} | ||
|
||
// NewSemverConstraintIC attempts to construct a semver Constraint object from the | ||
// input string, defaulting to a caret, ^, when no constraint is specified. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: s/constraint/operator/ |
||
// | ||
// If the input string cannot be made into a valid semver Constraint, an error | ||
// is returned. | ||
func NewSemverConstraintIC(body string) (Constraint, error) { | ||
c, err := semver.NewConstraintIC(body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
// If we got a simple semver.Version, simplify by returning our | ||
// corresponding type | ||
if sv, ok := c.(semver.Version); ok { | ||
return semVersion{sv: sv}, nil | ||
} | ||
return semverConstraint{c: c}, nil | ||
} | ||
|
||
type semverConstraint struct { | ||
c semver.Constraint | ||
} | ||
|
@@ -72,6 +98,16 @@ func (c semverConstraint) String() string { | |
return c.c.String() | ||
} | ||
|
||
// ImpliedCaretString converts the Constraint to a string in the same manner | ||
// as String(), but treats the empty operator as equivalent to ^, rather | ||
// than =. | ||
// | ||
// In the same way that String() is the inverse of NewConstraint(), this | ||
// method is the inverse of to NewSemverConstraintIC(). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "of to" |
||
func (c semverConstraint) ImpliedCaretString() string { | ||
return c.c.ImpliedCaretString() | ||
} | ||
|
||
func (c semverConstraint) typedString() string { | ||
return fmt.Sprintf("svc-%s", c.c.String()) | ||
} | ||
|
@@ -153,6 +189,10 @@ func (anyConstraint) String() string { | |
return "*" | ||
} | ||
|
||
func (anyConstraint) ImpliedCaretString() string { | ||
return "*" | ||
} | ||
|
||
func (anyConstraint) typedString() string { | ||
return "any-*" | ||
} | ||
|
@@ -177,6 +217,10 @@ func (noneConstraint) String() string { | |
return "" | ||
} | ||
|
||
func (noneConstraint) ImpliedCaretString() string { | ||
return "" | ||
} | ||
|
||
func (noneConstraint) typedString() string { | ||
return "none-" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: "of to"