Fix blog template generator to support calver
This commit is contained in:
@@ -72,11 +72,13 @@ class BlogTemplateGenerator {
|
|||||||
// springframework/cloud/spring-cloud-dependencies/Dalston.RELEASE/)
|
// springframework/cloud/spring-cloud-dependencies/Dalston.RELEASE/)
|
||||||
// - [Spring Milestone](https://repo.spring.io/milestone/) repository
|
// - [Spring Milestone](https://repo.spring.io/milestone/) repository
|
||||||
// releaseVersion '- Dalston.RELEASE
|
// releaseVersion '- Dalston.RELEASE
|
||||||
boolean release = this.releaseVersion.contains("RELEASE");
|
boolean release = !SR_PATTERN.matcher(this.releaseVersion).matches()
|
||||||
|
&& !RC_PATTERN.matcher(this.releaseVersion).matches()
|
||||||
|
&& !MILESTONE_PATTERN.matcher(this.releaseVersion).matches();
|
||||||
boolean nonRelease = !(release
|
boolean nonRelease = !(release
|
||||||
|| SR_PATTERN.matcher(this.releaseVersion).matches());
|
|| SR_PATTERN.matcher(this.releaseVersion).matches());
|
||||||
String availability = availability(release);
|
String availability = availability(release);
|
||||||
String releaseName = parsedReleaseName(this.releaseVersion);
|
String releaseName = parsedReleaseName(this.releaseVersion, release);
|
||||||
String releaseLink = link(nonRelease);
|
String releaseLink = link(nonRelease);
|
||||||
Map<String, Object> map = ImmutableMap.<String, Object>builder()
|
Map<String, Object> map = ImmutableMap.<String, Object>builder()
|
||||||
.put("availability", availability).put("releaseName", releaseName)
|
.put("availability", availability).put("releaseName", releaseName)
|
||||||
@@ -94,7 +96,16 @@ class BlogTemplateGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parsedReleaseName(String version) {
|
private String parsedReleaseName(String version, boolean release) {
|
||||||
|
if (version.split("\\.").length > 2) {
|
||||||
|
// Calver
|
||||||
|
if (release) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return version.substring(0, version.lastIndexOf("-"));
|
||||||
|
}
|
||||||
|
}
|
||||||
return version.substring(0, version.indexOf("."));
|
return version.substring(0, version.indexOf("."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,30 @@ public class TemplateGeneratorTests {
|
|||||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'");
|
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_generate_blog_from_template_for_tag_without_v_prefix_release_using_calver()
|
||||||
|
throws IOException {
|
||||||
|
this.props.getPom().setBranch("2020.0.5");
|
||||||
|
Projects projects = new Projects(new HashSet<ProjectVersion>() {
|
||||||
|
{
|
||||||
|
add(new ProjectVersion("spring-cloud-sleuth", "1.0.0"));
|
||||||
|
add(new ProjectVersion("spring-cloud-consul", "1.0.1"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
File generatedBlog = new TemplateGenerator(this.props, this.handler)
|
||||||
|
.blog(projects);
|
||||||
|
|
||||||
|
then(content(generatedBlog))
|
||||||
|
.contains("General Availability (RELEASE) of the [Spring Cloud 2020.0.5]")
|
||||||
|
.contains("The release can be found in [Maven Central]")
|
||||||
|
.contains("### Spring Cloud Sleuth")
|
||||||
|
.contains(
|
||||||
|
"| Spring Cloud Sleuth | 1.0.0 | ([issues](https://foo.bar.com))")
|
||||||
|
.contains("<version>2020.0.5</version>").contains(
|
||||||
|
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2020.0.5'");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_generate_sr_blog_from_template_for_tag_with_v_prefix_release()
|
public void should_generate_sr_blog_from_template_for_tag_with_v_prefix_release()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -250,6 +274,32 @@ public class TemplateGeneratorTests {
|
|||||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.M1'");
|
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.M1'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_generate_milestone_blog_from_template_for_tag_without_v_prefix_release_calver()
|
||||||
|
throws IOException {
|
||||||
|
this.props.getPom().setBranch("2020.0.0-M1");
|
||||||
|
Projects projects = new Projects(new HashSet<ProjectVersion>() {
|
||||||
|
{
|
||||||
|
add(new ProjectVersion("spring-cloud-sleuth", "1.0.0-M1"));
|
||||||
|
add(new ProjectVersion("spring-cloud-consul", "1.0.1-M1"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
File generatedBlog = new TemplateGenerator(this.props, this.handler)
|
||||||
|
.blog(projects);
|
||||||
|
|
||||||
|
then(content(generatedBlog))
|
||||||
|
.contains("Milestone 1 (M1) of the [Spring Cloud 2020.0.0]")
|
||||||
|
.contains("The release can be found in [Spring Milestone]")
|
||||||
|
.contains("### Spring Cloud Sleuth")
|
||||||
|
.contains(
|
||||||
|
"| Spring Cloud Sleuth | 1.0.0-M1 | ([issues](https://foo.bar.com))")
|
||||||
|
.contains("<id>spring-milestones</id>")
|
||||||
|
.contains("url 'https://repo.spring.io/milestone'")
|
||||||
|
.contains("<version>2020.0.0-M1</version>").contains(
|
||||||
|
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2020.0.0-M1'");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_generate_rc_blog_from_template_for_tag_with_v_prefix_release()
|
public void should_generate_rc_blog_from_template_for_tag_with_v_prefix_release()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -302,6 +352,32 @@ public class TemplateGeneratorTests {
|
|||||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RC1'");
|
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RC1'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_generate_rc_blog_from_template_for_tag_without_v_prefix_release_calver()
|
||||||
|
throws IOException {
|
||||||
|
this.props.getPom().setBranch("2020.0.0-RC1");
|
||||||
|
Projects projects = new Projects(new HashSet<ProjectVersion>() {
|
||||||
|
{
|
||||||
|
add(new ProjectVersion("spring-cloud-sleuth", "1.0.0-RC1"));
|
||||||
|
add(new ProjectVersion("spring-cloud-consul", "1.0.1-RC1"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
File generatedBlog = new TemplateGenerator(this.props, this.handler)
|
||||||
|
.blog(projects);
|
||||||
|
|
||||||
|
then(content(generatedBlog))
|
||||||
|
.contains("Release Candidate 1 (RC1) of the [Spring Cloud 2020.0.0]")
|
||||||
|
.contains("The release can be found in [Spring Milestone]")
|
||||||
|
.contains("### Spring Cloud Sleuth")
|
||||||
|
.contains(
|
||||||
|
"| Spring Cloud Sleuth | 1.0.0-RC1 | ([issues](https://foo.bar.com))")
|
||||||
|
.contains("<id>spring-milestones</id>")
|
||||||
|
.contains("url 'https://repo.spring.io/milestone'")
|
||||||
|
.contains("<version>2020.0.0-RC1</version>").contains(
|
||||||
|
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2020.0.0-RC1'");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_generate_release_notes_template_when_url_exists()
|
public void should_generate_release_notes_template_when_url_exists()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user