Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (p *Parser) ToVersString(r *Range, scheme string) string {
return fmt.Sprintf("vers:%s/*", scheme)
}
// Check if empty but has raw constraints (preserve them for output)
if r.IsEmpty() && len(r.RawConstraints) == 0 {
if r.isEmptyFor(scheme) && len(r.RawConstraints) == 0 {
return fmt.Sprintf("vers:%s/", scheme)
}

Expand Down
18 changes: 18 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,24 @@ func TestToVersString(t *testing.T) {
"npm",
"vers:npm/>=1.0.0|<2.0.0",
},
{
"schemeless pypi calver range",
NewRange([]Interval{NewInterval("2016.11.0", "3003rc1", true, false)}),
"pypi",
"vers:pypi/>=2016.11.0|<3003rc1",
},
{
"schemeless pypi dev range",
NewRange([]Interval{NewInterval("0.5.0b3.dev13", "0.5.0b3.dev97", true, false)}),
"pypi",
"vers:pypi/>=0.5.0b3.dev13|<0.5.0b3.dev97",
},
{
"schemeless empty interval",
NewRange([]Interval{NewInterval("2.0", "1.0", true, false)}),
"pypi",
"vers:pypi/",
},
}

for _, tt := range tests {
Expand Down
6 changes: 5 additions & 1 deletion range.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ func samePEP440Release(left, right pep440Version) bool {

// IsEmpty returns true if this range matches no versions.
func (r *Range) IsEmpty() bool {
return r.isEmptyFor(r.Scheme)
}

func (r *Range) isEmptyFor(scheme string) bool {
if len(r.Intervals) == 0 {
return true
}
cmp := compareFuncFor(r.Scheme)
cmp := compareFuncFor(scheme)
for _, interval := range r.Intervals {
if !interval.isEmptyCmp(cmp) {
return false
Expand Down
Loading