Skip to content
Permalink
Browse files
Add buildnum extraction support for OpenJFX tags
Reviewed-by: kcr, ehelin
  • Loading branch information
rwestberg committed Nov 8, 2019
1 parent e294ce9 commit 069620bcd3a2dc8128431f2b473c63b23eaf647d
Showing with 28 additions and 3 deletions.
  1. +7 −1 vcs/src/main/java/org/openjdk/skara/vcs/openjdk/OpenJDKTag.java
  2. +21 −2 vcs/src/test/java/org/openjdk/skara/vcs/openjdk/OpenJDKTagTests.java
@@ -52,16 +52,19 @@ private OpenJDKTag(Tag tag, String prefix, String version, String buildPrefix, S
* jdk7u40-b20 -> jdk7u40 7u40 u20 -b 29
* hs24-b30 -> hs24 24 -b 30
* hs23.6-b19 -> hs23.6 23.6 .6 -b 19
* 11.1+22 -> 11.1 11.1 .1 + 22
*/

private final static String legacyOpenJDKVersionPattern = "(jdk([0-9]{1,2}(u[0-9]{1,3})?))";
private final static String legacyHSVersionPattern = "((hs[0-9]{1,2}(\\.[0-9]{1,3})?))";
private final static String legacyBuildPattern = "(-b)([0-9]{2,3})";
private final static String OpenJDKVersionPattern = "(jdk-([0-9]+(\\.[0-9]){0,3}))(\\+)([0-9]+)";
private final static String OpenJFXVersionPattern = "((?:jdk-){0,1}([1-9](?:(?:[0-9]*)(\\.(?:0|[1-9][0-9]*)){0,3})))(?:(\\+)([0-9]+)|(-ga))";

private final static List<Pattern> tagPatterns = List.of(Pattern.compile(legacyOpenJDKVersionPattern + legacyBuildPattern),
Pattern.compile(legacyHSVersionPattern + legacyBuildPattern),
Pattern.compile(OpenJDKVersionPattern));
Pattern.compile(OpenJDKVersionPattern),
Pattern.compile(OpenJFXVersionPattern));

/**
* Attempts to create an OpenJDKTag instance from a general Tag.
@@ -106,6 +109,9 @@ public String version() {
* @return
*/
public int buildNum() {
if (buildNum == null) {
return 0;
}
return Integer.parseInt(buildNum);
}

@@ -22,10 +22,11 @@
*/
package org.openjdk.skara.vcs.openjdk;

import org.openjdk.skara.vcs.Tag;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

import org.openjdk.skara.vcs.Tag;
import static org.junit.jupiter.api.Assertions.*;

class OpenJDKTagTests {
@Test
@@ -92,4 +93,22 @@ void noPrevious() {
assertEquals(0, jdkTag.buildNum());
assertFalse(jdkTag.previous().isPresent());
}

@Test
void parseJfxTags() {
var tag = new Tag("12.1.3+14");
var jdkTag = OpenJDKTag.create(tag).orElseThrow();
assertEquals("12.1.3", jdkTag.version());
assertEquals(14, jdkTag.buildNum());
var previousTag = jdkTag.previous().orElseThrow();
assertEquals(13, previousTag.buildNum());
}

@Test
void parseJfxTagsGa() {
var tag = new Tag("12.1-ga");
var jdkTag = OpenJDKTag.create(tag).orElseThrow();
assertEquals("12.1", jdkTag.version());
assertEquals(0, jdkTag.buildNum());
}
}

0 comments on commit 069620b

Please sign in to comment.