Skip to content

Commit

Permalink
Merge pull request #328 from zvezdan/fix-pivy-version-matching
Browse files Browse the repository at this point in the history
Fix the edge case version comparison in pivy-importer.
  • Loading branch information
zvezdan authored Nov 27, 2019
2 parents 390636f + 7ec2379 commit 445bf08
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ class ProjectDetails {
// skip alpha/beta/release candidate versions
continue
}
if (VersionRange.compareVersions(release, start) > 0 || (release == start && range.includeStart)) {
if (VersionRange.compareVersions(release, start) > 0 ||
((release == start || VersionRange.compareVersions(release, start) == 0) && range.includeStart)) {
matchingRange.add(release)
}
if (VersionRange.compareVersions(release, end) > 0 || (release == end && !range.includeEnd)) {
if (VersionRange.compareVersions(release, end) > 0 ||
((release == end || VersionRange.compareVersions(release, end) == 0) && !range.includeEnd)) {
break
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,24 @@ class VersionRange {
}
if (v1.size() == v2.size()) {
return 0
} else if (i < v2.size()) {
}
// Make sure 0.3 matches 0.3.0, etc.
if (i < v1.size() && isOnlyZeroesRemain(v1, i) || i < v2.size() && isOnlyZeroesRemain(v2, i)) {
return 0
}
if (i < v2.size()) {
return (v2[i] < 0) ? 1 : -1
}
return (v1[i] < 0) ? -1 : 1
}

static boolean isOnlyZeroesRemain(List<Integer> v, int start) {
for (int i = start; i < v.size(); i++) {
if (v[i] != 0) {
return false
}
}
return true
}

}

0 comments on commit 445bf08

Please sign in to comment.