Recognize calver release and service release.
This commit is contained in:
@@ -413,7 +413,16 @@ public class ProjectVersion implements Comparable<ProjectVersion>, Serializable
|
||||
}
|
||||
|
||||
public boolean isRelease() {
|
||||
return this.version != null && this.version.contains("RELEASE");
|
||||
if (!StringUtils.hasText(this.version)) {
|
||||
return false;
|
||||
}
|
||||
SplitVersion splitVersion = assertVersion();
|
||||
if (splitVersion.calverReleaseTrain()) {
|
||||
if (Integer.parseInt(splitVersion.patch) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.version.contains("RELEASE");
|
||||
}
|
||||
|
||||
public boolean isReleaseTrain() {
|
||||
@@ -431,7 +440,16 @@ public class ProjectVersion implements Comparable<ProjectVersion>, Serializable
|
||||
}
|
||||
|
||||
public boolean isServiceRelease() {
|
||||
return this.version != null && this.version.matches(".*.SR[0-9]+");
|
||||
if (!StringUtils.hasText(this.version)) {
|
||||
return false;
|
||||
}
|
||||
SplitVersion splitVersion = assertVersion();
|
||||
if (splitVersion.calverReleaseTrain()) {
|
||||
if (Integer.parseInt(splitVersion.patch) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.version.matches(".*.SR[0-9]+");
|
||||
}
|
||||
|
||||
private ReleaseType toReleaseType() {
|
||||
@@ -696,7 +714,12 @@ public class ProjectVersion implements Comparable<ProjectVersion>, Serializable
|
||||
}
|
||||
|
||||
private boolean calverReleaseTrain() {
|
||||
return Integer.parseInt(this.major) >= 2020;
|
||||
try {
|
||||
return Integer.parseInt(this.major) >= 2020;
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOldReleaseTrain() {
|
||||
|
||||
@@ -110,7 +110,8 @@ public class ProjectVersionTests {
|
||||
then(ProjectVersion.isValid("2020.0.0-SNAPSHOT")).isTrue();
|
||||
then(ProjectVersion.isValid("2020.0.0-M1")).isTrue();
|
||||
then(ProjectVersion.isValid("2020.0.0-RC2")).isTrue();
|
||||
// then(ProjectVersion.isValid("2020.0.0")).isTrue();
|
||||
then(ProjectVersion.isValid("2020.0.0")).isTrue();
|
||||
then(ProjectVersion.isValid("2020.1.1")).isTrue();
|
||||
then(ProjectVersion.isValid("1.0.1-SNAPSHOT")).isTrue();
|
||||
then(ProjectVersion.isValid("1.0.3-RC1")).isTrue();
|
||||
then(ProjectVersion.isValid("1.0.4-M1")).isTrue();
|
||||
@@ -152,7 +153,8 @@ public class ProjectVersionTests {
|
||||
then(projectVersion("2.0.1-RC1").major()).isEqualTo("2");
|
||||
then(projectVersion("Finchley-SR1").major()).isEqualTo("Finchley");
|
||||
then(projectVersion("2020.0.0-M1").major()).isEqualTo("2020");
|
||||
// then(projectVersion("2020.0.0").major()).isEqualTo("2020");
|
||||
then(projectVersion("2020.0.0").major()).isEqualTo("2020");
|
||||
then(projectVersion("2021.1.1").major()).isEqualTo("2021");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,7 +270,7 @@ public class ProjectVersionTests {
|
||||
|
||||
String newReleaseSuffixVersion = "2020.0.0";
|
||||
|
||||
// then(projectVersion(newReleaseSuffixVersion).isRelease()).isTrue();
|
||||
then(projectVersion(newReleaseSuffixVersion).isRelease()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -279,7 +281,7 @@ public class ProjectVersionTests {
|
||||
|
||||
String newServiceReleaseVersion = "2020.0.1";
|
||||
|
||||
// then(projectVersion(newServiceReleaseVersion).isRelease()).isTrue();
|
||||
then(projectVersion(newServiceReleaseVersion).isServiceRelease()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user