Skip to content

Commit

Permalink
fixing the LatestRelease support for maven LATEST/RELEASE syntax to b…
Browse files Browse the repository at this point in the history
…e symmetrical
  • Loading branch information
nmck257 committed Sep 9, 2024
1 parent 0bcb570 commit 4a98c3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ static int countVersionParts(String version) {
public int compare(@Nullable String currentVersion, String v1, String v2) {
if (v1.equalsIgnoreCase(v2)) {
return 0;
}
if (v1.equalsIgnoreCase("RELEASE")) {
return v2.equalsIgnoreCase("LATEST") ? -1 : 1;
}
if (v1.equalsIgnoreCase("LATEST")) {
} else if (v1.equalsIgnoreCase("LATEST")) {
return 1;
} else if (v2.equalsIgnoreCase("LATEST")) {
return -1;
} else if (v1.equalsIgnoreCase("RELEASE")) {
return 1;
} else if (v2.equalsIgnoreCase("RELEASE")) {
return -1;
}

String nv1 = normalizeVersion(v1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ void preReleases() {
@Test
void releaseOrLatestKeyword_beatsEverything() {
assertThat(latestRelease.compare(null, "RELEASE", "1.2.3")).isPositive();
assertThat(latestRelease.compare(null, "1.2.3", "RELEASE")).isNegative();
assertThat(latestRelease.compare(null, "RELEASE", "999.999.999")).isPositive();
assertThat(latestRelease.compare(null, "RELEASE", "RELEASE")).isZero();

assertThat(latestRelease.compare(null, "LATEST", "1.2.3")).isPositive();
assertThat(latestRelease.compare(null, "1.2.3", "LATEST")).isNegative();
assertThat(latestRelease.compare(null, "LATEST", "999.999.999")).isPositive();
assertThat(latestRelease.compare(null, "LATEST", "LATEST")).isZero();

Expand Down

0 comments on commit 4a98c3b

Please sign in to comment.