File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
main/java/com/datastax/driver/core
test/java/com/datastax/driver/core Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 34
34
public class VersionNumber implements Comparable <VersionNumber > {
35
35
36
36
private static final String VERSION_REGEXP =
37
- "(\\ d+)\\ .(\\ d+)(\\ .\\ d+)?(\\ .\\ d+)?([~\\ -]\\ w[.\\ w]*(?:\\ -\\ w[.\\ w]*)*)?(\\ +[.\\ w]+)?" ;
37
+ "(\\ d+)\\ .(\\ d+)(\\ .(?:rc)? \\ d+)?(\\ .\\ d+)?([~\\ -]\\ w[.\\ w]*(?:\\ -\\ w[.\\ w]*)*)?(\\ +[.\\ w]+)?" ;
38
38
private static final Pattern pattern = Pattern .compile (VERSION_REGEXP );
39
39
40
40
private final int major ;
@@ -79,8 +79,9 @@ public static VersionNumber parse(String version) {
79
79
int minor = Integer .parseInt (matcher .group (2 ));
80
80
81
81
String pa = matcher .group (3 );
82
+ boolean isRC = pa != null && pa .startsWith (".rc" ); // Detect Scylla naming convention: X.Y.rcZ
82
83
int patch =
83
- pa == null || pa .isEmpty ()
84
+ pa == null || pa .isEmpty () || isRC
84
85
? 0
85
86
: Integer .parseInt (
86
87
pa .substring (1 )); // dropping the initial '.' since it's included this time
@@ -94,10 +95,12 @@ public static VersionNumber parse(String version) {
94
95
95
96
String pr = matcher .group (5 );
96
97
String [] preReleases =
97
- pr == null || pr .isEmpty ()
98
- ? null
99
- : pr .substring (1 )
100
- .split ("\\ -" ); // drop initial '-' or '~' then split on the remaining ones
98
+ isRC
99
+ ? new String [] {pa .substring (1 )}
100
+ : pr == null || pr .isEmpty ()
101
+ ? null
102
+ : pr .substring (1 )
103
+ .split ("\\ -" ); // drop initial '-' or '~' then split on the remaining ones
101
104
102
105
String bl = matcher .group (6 );
103
106
String build = bl == null || bl .isEmpty () ? null : bl .substring (1 ); // drop the initial '+'
Original file line number Diff line number Diff line change @@ -106,6 +106,14 @@ public void should_treat_same_prerelease_equal() {
106
106
assertThat (version1 .hashCode ()).isEqualTo (version2 .hashCode ());
107
107
}
108
108
109
+ @ Test (groups = "unit" )
110
+ public void should_parse_scylla_release_candidates () {
111
+ assertThat (VersionNumber .parse ("4.3.rc5" ))
112
+ .hasMajorMinorPatch (4 , 3 , 0 )
113
+ .hasToString ("4.3.0-rc5" )
114
+ .hasPreReleaseLabels ("rc5" );
115
+ }
116
+
109
117
private void assertOrder (String version1 , String version2 , int expected ) {
110
118
assertThat (VersionNumber .parse (version1 ).compareTo (VersionNumber .parse (version2 )))
111
119
.isEqualTo (expected );
You can’t perform that action at this time.
0 commit comments