This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 385328e  Fix parsing of patch versions in `log4j-changelog:release` 
goal (#89)
385328e is described below

commit 385328e96987dbcad2a895c7fea8668dc6b42e50
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Wed Dec 13 12:33:34 2023 +0100

    Fix parsing of patch versions in `log4j-changelog:release` goal (#89)
---
 .../changelog/releaser/ChangelogReleaserArgs.java  | 11 ++++++++--
 .../releaser/ChangelogReleaserArgsTest.java        |  3 +++
 src/changelog/.0.x.x/fix-releaser-regex.xml        | 24 ++++++++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git 
a/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgs.java
 
b/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgs.java
index 21d1f86..6825c56 100644
--- 
a/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgs.java
+++ 
b/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgs.java
@@ -26,8 +26,7 @@ import java.util.regex.Pattern;
 @SuppressFBWarnings("REDOS")
 public final class ChangelogReleaserArgs {
 
-    static final Pattern DEFAULT_VERSION_PATTERN = 
Pattern.compile("^(?<major>0|[1-9]\\d*)\\."
-            + "(?<minor>0|[1-9]\\d*)\\." + 
"(?<patch>0|[1-9]\\d*(-[a-zA-Z][0-9a-zA-Z-]*)?)$");
+    static final Pattern DEFAULT_VERSION_PATTERN = 
createDefaultVersionPattern();
 
     final Path changelogDirectory;
 
@@ -37,6 +36,14 @@ public final class ChangelogReleaserArgs {
 
     final LocalDate releaseDate;
 
+    private static Pattern createDefaultVersionPattern() {
+        final String majorPattern = "(?<minor>0|[1-9]\\d*)";
+        final String minorPattern = "(?<major>0|[1-9]\\d*)";
+        final String patchPattern = 
"(?<patch>(0|[1-9]\\d*)(-[a-zA-Z][0-9a-zA-Z-]*)?)";
+        final String pattern = String.format("^%s\\.%s\\.%s$", minorPattern, 
majorPattern, patchPattern);
+        return Pattern.compile(pattern);
+    }
+
     public ChangelogReleaserArgs(
             final Path changelogDirectory,
             final String releaseVersion,
diff --git 
a/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgsTest.java
 
b/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgsTest.java
index 44129ef..8043742 100644
--- 
a/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgsTest.java
+++ 
b/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/releaser/ChangelogReleaserArgsTest.java
@@ -29,8 +29,11 @@ class ChangelogReleaserArgsTest {
     @CsvSource({
         "0.0.1,0,0,1",
         "0.1.0,0,1,0",
+        "1.2.0-alpha1,1,2,0-alpha1",
         "1.2.3-alpha1,1,2,3-alpha1",
+        "1.2.0-beta1,1,2,0-beta1",
         "1.2.3-beta1,1,2,3-beta1",
+        "1.2.0-rc1,1,2,0-rc1",
         "1.2.3-rc1,1,2,3-rc1",
         "1.2.3-SNAPSHOT,1,2,3-SNAPSHOT"
     })
diff --git a/src/changelog/.0.x.x/fix-releaser-regex.xml 
b/src/changelog/.0.x.x/fix-releaser-regex.xml
new file mode 100644
index 0000000..136c7dd
--- /dev/null
+++ b/src/changelog/.0.x.x/fix-releaser-regex.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns="http://logging.apache.org/log4j/changelog";
+       xsi:schemaLocation="http://logging.apache.org/log4j/changelog 
https://logging.apache.org/log4j/changelog-0.1.2.xsd";
+       type="fixed">
+  <issue id="89" 
link="https://github.com/apache/logging-log4j-tools/issues/89"/>
+  <description format="asciidoc">Fix parsing of patch versions in 
`log4j-changelog:release` goal</description>
+</entry>

Reply via email to