From a0f4e95e00edcc7899cee26eb338a230bcaaad7f Mon Sep 17 00:00:00 2001 From: Stu Arnett Date: Wed, 18 Feb 2015 15:23:09 -0600 Subject: [PATCH] add option to delete existing files in branch (default true - backward compatible) --- .../ajoberstar/gradle/git/ghpages/GithubPagesPlugin.groovy | 2 +- .../gradle/git/ghpages/GithubPagesPluginExtension.groovy | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPlugin.groovy b/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPlugin.groovy index 08aa97e..9c9551a 100644 --- a/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPlugin.groovy +++ b/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPlugin.groovy @@ -58,7 +58,7 @@ class GithubPagesPlugin implements Plugin { def filesList = extension.workingDir.list({ dir, name -> return !name.equals('.git') }) - if (filesList) { + if (filesList && extension.deleteExistingFiles) { repo.remove(patterns: filesList) } project.copy { diff --git a/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPluginExtension.groovy b/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPluginExtension.groovy index b27bbb5..e30a3e9 100644 --- a/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPluginExtension.groovy +++ b/src/main/groovy/org/ajoberstar/gradle/git/ghpages/GithubPagesPluginExtension.groovy @@ -55,6 +55,12 @@ class GithubPagesPluginExtension implements AuthenticationSupported { */ Object workingPath = "${project.buildDir}/ghpages" + /** + * Whether to delete existing files in the branch, replacing the + * entire contents. Defaults to {@code true}. + */ + boolean deleteExistingFiles = true + /** * The message used when committing changes to Github pages branch. * Defaults to 'Publish of Github pages from Gradle.'.