diff --git a/src/main/java/org/jabref/logic/util/Version.java b/src/main/java/org/jabref/logic/util/Version.java index 0775fd6a0fb..06270ceba67 100644 --- a/src/main/java/org/jabref/logic/util/Version.java +++ b/src/main/java/org/jabref/logic/util/Version.java @@ -29,8 +29,9 @@ public class Version { private static final Version UNKNOWN_VERSION = new Version(); private final static Pattern VERSION_PATTERN = Pattern.compile("(?\\d+)(\\.(?\\d+))?(\\.(?\\d+))?(?-alpha|-beta)?(?-?dev)?.*"); - private static final String JABREF_GITHUB_RELEASES = "https://api.github.com/repos/JabRef/JabRef/releases"; + private final static Pattern CI_SUFFIX_PATTERN = Pattern.compile("-ci\\.\\d+$"); + private static final String JABREF_GITHUB_RELEASES = "https://api.github.com/repos/JabRef/JabRef/releases"; private String fullVersion = BuildInfo.UNKNOWN_VERSION; private int major = -1; @@ -58,6 +59,10 @@ public static Version parse(String version) { Version parsedVersion = new Version(); + // remove "-ci.1" suffix + Matcher ciSuffixMatcher = CI_SUFFIX_PATTERN.matcher(version); + version = ciSuffixMatcher.replaceAll(""); + parsedVersion.fullVersion = version; Matcher matcher = VERSION_PATTERN.matcher(version); if (matcher.find()) { @@ -277,7 +282,7 @@ public static DevelopmentStage parse(String stage) { } else if (stage.equals(BETA.stage)) { return BETA; } - LOGGER.warn("Unknown development stage: " + stage); + LOGGER.warn("Unknown development stage: {}", stage); return UNKNOWN; } diff --git a/src/test/java/org/jabref/logic/util/VersionTest.java b/src/test/java/org/jabref/logic/util/VersionTest.java index 7601f29910e..580e6deae85 100644 --- a/src/test/java/org/jabref/logic/util/VersionTest.java +++ b/src/test/java/org/jabref/logic/util/VersionTest.java @@ -282,4 +282,10 @@ public void alphaShouldBeUpdatedToStables() { List availableVersions = Arrays.asList(Version.parse("2.8-beta"), stable); assertEquals(Optional.of(stable), alpha.shouldBeUpdatedTo(availableVersions)); } + + @Test + public void ciSuffixShouldBeRemoved() { + Version v50ci = Version.parse("5.0-ci.1"); + assertEquals("5.0", v50ci.getFullVersion()); + } }