Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buildnum extraction support for OpenJFX tags #241

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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))";
Copy link
Member

@kevinrushforth kevinrushforth Nov 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this change, but the OpenJDKVersionPattern also will need support for *-ga tags.


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) {
Copy link
Member

@kevinrushforth kevinrushforth Nov 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what conditions will this be null? When using a *-ga tag? If so, this seems fine.

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());
}
}