Skip to content

Commit

Permalink
Remove suffix "-ci.1" from version information stored in BuildInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Mar 4, 2020
1 parent 8660e29 commit 2978dee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/jabref/logic/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public class Version {
private static final Version UNKNOWN_VERSION = new Version();

private final static Pattern VERSION_PATTERN = Pattern.compile("(?<major>\\d+)(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?(?<stage>-alpha|-beta)?(?<dev>-?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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/jabref/logic/util/VersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,10 @@ public void alphaShouldBeUpdatedToStables() {
List<Version> 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());
}
}

0 comments on commit 2978dee

Please sign in to comment.