Skip to content

Commit

Permalink
Merge pull request #38 from ajoberstar/repodir
Browse files Browse the repository at this point in the history
0.3.1
  • Loading branch information
ajoberstar authored Oct 13, 2017
2 parents 12e6deb + bdd4e98 commit c8e1fa3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ gitPublish {
remoteFile('content.txt').text == 'published content here'
}

def 'can customize working directory'() {
given:
projectFile('src/content.txt') << 'published content here'

buildFile << """
plugins {
id 'org.ajoberstar.git-publish'
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoDir = file('build/this-is-custom')
branch = 'gh-pages'
contents.from 'src'
}
"""
when:
def result = build()
then:
projectFile('build/this-is-custom/content.txt').exists()
}

def 'can preserve specific files'() {
given:
projectFile('src/content.txt') << 'published content here'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GitPublishPlugin implements Plugin<Project> {
Task reset = createResetTask(project, extension)
Task copy = createCopyTask(project, extension)
Task commit = createCommitTask(project, extension)
Task push = createPushTask(project, extension)
Task push = createPushTask(project, extension, commit)
push.dependsOn commit
commit.dependsOn copy
copy.dependsOn reset
Expand Down Expand Up @@ -126,7 +126,7 @@ class GitPublishPlugin implements Plugin<Project> {
group = 'publishing'
description = 'Copy contents to be published to git.'
with extension.contents
into extension.repoDir
into { extension.repoDir }
}
return task
}
Expand All @@ -151,13 +151,13 @@ class GitPublishPlugin implements Plugin<Project> {
return task
}

private Task createPushTask(Project project, GitPublishExtension extension) {
private Task createPushTask(Project project, GitPublishExtension extension, Task commit) {
Task task = project.tasks.create(PUSH_TASK)
task.with {
group = 'publishing'
description = 'Pushes changes to git.'
// if we didn't commit anything, don't push anything
onlyIf { dependsOnTaskDidWork() }
onlyIf { commit.didWork }
doLast {
extension.repo.push()
}
Expand Down

0 comments on commit c8e1fa3

Please sign in to comment.