Added a guard for non spring cloud projects docs update
fixes gh-177
This commit is contained in:
@@ -62,6 +62,12 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
@Override
|
||||
public File updateDocsRepoForReleaseTrain(File clonedDocumentationProject,
|
||||
ProjectVersion currentProject, Projects projects, String bomBranch) {
|
||||
if (!currentProject.projectName.startsWith("spring-cloud")) {
|
||||
log.info(
|
||||
"Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
|
||||
currentProject.projectName);
|
||||
return clonedDocumentationProject;
|
||||
}
|
||||
log.debug("Cloning the doc project to [{}]", clonedDocumentationProject);
|
||||
ProjectVersion releaseTrainProject = new ProjectVersion(
|
||||
this.releaserProperties.getMetaRelease().getReleaseTrainProjectName(),
|
||||
@@ -91,6 +97,12 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
currentProject.projectName, projects);
|
||||
return clonedDocumentationProject;
|
||||
}
|
||||
if (!currentProject.projectName.startsWith("spring-cloud")) {
|
||||
log.info(
|
||||
"Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
|
||||
currentProject.projectName);
|
||||
return clonedDocumentationProject;
|
||||
}
|
||||
log.info("Updating link to documentation for project [{}]",
|
||||
currentProject.projectName);
|
||||
ProjectVersion currentProjectVersion = projects
|
||||
@@ -158,16 +170,6 @@ class SpringCloudCustomProjectDocumentationUpdater
|
||||
return last > 0 ? path.substring(last + 1) : path;
|
||||
}
|
||||
|
||||
private String concreteVersionFolder(ProjectVersion projectVersion) {
|
||||
String projectName = projectVersion.projectName;
|
||||
boolean releaseTrain = projectVersion.isReleaseTrain();
|
||||
// release train -> static/Hoxton.SR2/
|
||||
// project -> static/spring-cloud-sleuth/1.2.3.RELEASE/
|
||||
String prefix = releaseTrain ? projectVersion.version
|
||||
: (projectName + "/" + projectVersion.version);
|
||||
return prefix + "/";
|
||||
}
|
||||
|
||||
private File pushChanges(File docsRepo) {
|
||||
this.gitHandler.pushCurrentBranch(docsRepo);
|
||||
log.info("Committed and pushed changes to the documentation project");
|
||||
|
||||
@@ -163,6 +163,36 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_do_nothing_when_release_train_docs_update_happen_for_a_project_that_does_not_start_with_spring_cloud() {
|
||||
ProjectVersion springBootVersion = new ProjectVersion("spring-boot", "2.2.5");
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
|
||||
|
||||
new SpringCloudCustomProjectDocumentationUpdater(handler, properties)
|
||||
.updateDocsRepoForReleaseTrain(this.clonedDocProject, springBootVersion,
|
||||
bootProject(), "vDalston.SR3");
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_do_nothing_when_single_project_docs_update_happen_for_a_project_that_does_not_start_with_spring_cloud() {
|
||||
ProjectVersion springBootVersion = new ProjectVersion("spring-boot", "2.2.5");
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
|
||||
|
||||
new SpringCloudCustomProjectDocumentationUpdater(handler, properties)
|
||||
.updateDocsRepoForSingleProject(this.clonedDocProject, springBootVersion,
|
||||
bootProject());
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_lower_letter_than_the_stored_release()
|
||||
throws IOException {
|
||||
@@ -261,4 +291,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
return new Projects(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE"));
|
||||
}
|
||||
|
||||
private Projects bootProject() {
|
||||
return new Projects(new ProjectVersion("spring-boot", "2.2.5.RELEASE"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user