Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] Semantic Versioning regex update (#93)
Browse files Browse the repository at this point in the history
* rolling release test

* regex update
  • Loading branch information
abrams27 authored Aug 26, 2021
1 parent bc595b2 commit c25a04f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class SemanticVersion implements Comparable<SemanticVersion> {

private static final String SEMANTIC_VERSION_REGEX =
"^([0-9]+)\\.([0-9]+)\\.([0-9]+)[\\-a-zA-Z]*";
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$";
private static final int MAJOR_VERSION_GROUP_ID = 1;
private static final int MINOR_VERSION_GROUP_ID = 2;
private static final int PATCH_VERSION_GROUP_ID = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ public void shouldParseHomebrewVersion() {
assertEquals(2, version.getMinorVersion());
assertEquals(3, version.getPatchVersion());
}

@Test
public void shouldParseRollingRelease() {
SemanticVersion version = new SemanticVersion("5.0.0-pre.20210817.2");

assertEquals(5, version.getMajorVersion());
assertEquals(0, version.getMinorVersion());
assertEquals(0, version.getPatchVersion());
}
}

0 comments on commit c25a04f

Please sign in to comment.