Skip to content

Commit

Permalink
LatestRelease should replace metadataPattern as regex, as documen…
Browse files Browse the repository at this point in the history
…ted (#4894)

* Fix version comparator

* LatestRelease.metadataPattern should be matched as a regex

---------

Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
ZhyliaievD and timtebeek authored Jan 13, 2025
1 parent 30c9156 commit cce9f3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ public int compare(@Nullable String currentVersion, String v1, String v2) {
// parts are the same:
//
// HyphenRange [25-28] should include "28-jre" and "28-android" as possible candidates.
String normalized1 = metadataPattern == null ? nv1 : nv1.replace(metadataPattern, "");
String normalized2 = metadataPattern == null ? nv2 : nv1.replace(metadataPattern, "");

String normalized1 = metadataPattern == null ? nv1 : nv1.replaceAll(metadataPattern, "");
String normalized2 = metadataPattern == null ? nv2 : nv2.replaceAll(metadataPattern, "");
try {
for (int i = 1; i <= Math.max(vp1, vp2); i++) {
String v1Part = v1Gav.group(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ void exactVersionWithExactPattern() {
@Issue("https://github.com/openrewrite/rewrite/issues/4333")
void exactVersionWithRegexPattern() {
rewriteRun(
spec -> spec.recipe(new UpgradeDependencyVersion("com.google.guava", "guava", "32.1.1", ".*droid")),
spec -> spec.recipe(new UpgradeDependencyVersion("com.google.guava", "guava", "32.1.1", "-.*?droid")),
buildGradle(
"""
plugins {
Expand Down

0 comments on commit cce9f3e

Please sign in to comment.