Switch for updating documentation; fixes gh-102

This commit is contained in:
Marcin Grzejszczak
2018-10-16 18:07:24 +02:00
parent e407255565
commit 2156fab4e7
6 changed files with 95 additions and 30 deletions

View File

@@ -149,6 +149,11 @@ public class ReleaserProperties implements Serializable {
*/
private String documentationBranch = "gh-pages";
/**
* If {@code false}, will not update the documentation repository.
*/
private boolean updateDocumentationRepo = true;
/**
* Where should the Spring Cloud Release repo get cloned to. If {@code null} defaults to a temporary directory
*/
@@ -204,6 +209,14 @@ public class ReleaserProperties implements Serializable {
this.documentationBranch = documentationBranch;
}
public boolean isUpdateDocumentationRepo() {
return this.updateDocumentationRepo;
}
public void setUpdateDocumentationRepo(boolean updateDocumentationRepo) {
this.updateDocumentationRepo = updateDocumentationRepo;
}
public String getCloneDestinationDir() {
return this.cloneDestinationDir;
}

View File

@@ -6,6 +6,8 @@ import java.nio.file.Files;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
import org.springframework.cloud.release.internal.pom.ProjectVersion;
@@ -18,9 +20,12 @@ public class DocumentationUpdater {
private static final Logger log = LoggerFactory.getLogger(DocumentationUpdater.class);
private final ProjectGitHandler gitHandler;
private final ReleaserProperties properties;
public DocumentationUpdater(ProjectGitHandler gitHandler) {
public DocumentationUpdater(ReleaserProperties properties,
ProjectGitHandler gitHandler) {
this.gitHandler = gitHandler;
this.properties = properties;
}
/**
@@ -32,6 +37,11 @@ public class DocumentationUpdater {
* @return {@link File cloned temporary directory} - {@code null} if wrong version is used
*/
public File updateDocsRepo(ProjectVersion currentProject, String springCloudReleaseBranch) {
if (!properties.getGit().isUpdateDocumentationRepo()) {
log.info("Will not update documentation repository, since the switch to do so "
+ "is off. Set [releaser.git.update-documentation-repo] to [true] to change that");
return null;
}
if (!currentProject.isReleaseOrServiceRelease()) {
log.info("Will not update documentation repository for non release or service release [{}]", currentProject.version);
return null;