From c0158582ed42fb0288deff2e41d7fdf72a1701a5 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 16 Apr 2024 15:14:24 +0200 Subject: [PATCH] Handle prefixing backport PRs correctly --- src/main/java/io/quarkus/bot/util/GHPullRequests.java | 2 +- src/test/java/io/quarkus/bot/it/util/GHPullRequestsTest.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/quarkus/bot/util/GHPullRequests.java b/src/main/java/io/quarkus/bot/util/GHPullRequests.java index ef89d9d..7904532 100644 --- a/src/main/java/io/quarkus/bot/util/GHPullRequests.java +++ b/src/main/java/io/quarkus/bot/util/GHPullRequests.java @@ -7,7 +7,7 @@ public final class GHPullRequests { - private static final Pattern CLEAN_VERSION_PATTERN = Pattern.compile("^\\[?\\(?[0-9]+\\.[0-9]+\\]?\\)?[ -]*"); + private static final Pattern CLEAN_VERSION_PATTERN = Pattern.compile("^\\[?\\(?[0-9]+\\.[0-9]+\\]?\\)?(?!\\.)[ -]*"); public static boolean hasLabel(GHPullRequest pullRequest, String labelName) { for (GHLabel label : pullRequest.getLabels()) { diff --git a/src/test/java/io/quarkus/bot/it/util/GHPullRequestsTest.java b/src/test/java/io/quarkus/bot/it/util/GHPullRequestsTest.java index d136aa4..8c776af 100644 --- a/src/test/java/io/quarkus/bot/it/util/GHPullRequestsTest.java +++ b/src/test/java/io/quarkus/bot/it/util/GHPullRequestsTest.java @@ -26,6 +26,7 @@ public void testNormalizeTitle() { assertThat(GHPullRequests.normalizeTitle("My PR", "3.10")).isEqualTo(("[3.10] My PR")); assertThat(GHPullRequests.normalizeTitle("My PR", "main")).isEqualTo(("My PR")); assertThat(GHPullRequests.normalizeTitle("(3.8) My PR", "main")).isEqualTo(("(3.8) My PR")); + assertThat(GHPullRequests.normalizeTitle("3.8.4 backports 1", "3.8")).isEqualTo(("[3.8] 3.8.4 backports 1")); assertThat(GHPullRequests.normalizeTitle("(3.10) My PR", "3.10")).isEqualTo(("[3.10] My PR")); assertThat(GHPullRequests.normalizeTitle("[3.8] My PR", "main")).isEqualTo(("[3.8] My PR")); assertThat(GHPullRequests.normalizeTitle("[3.8] My PR", "3.8")).isEqualTo(("[3.8] My PR"));