Skip to content

Commit

Permalink
Merge pull request #53 from ajoberstar/no-reset
Browse files Browse the repository at this point in the history
Don't close grgit if it's not present
  • Loading branch information
ajoberstar authored Jun 6, 2018
2 parents ca1bcac + bbce438 commit af6ec70
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.ajoberstar.grgit.Grgit
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import org.gradle.testkit.runner.UnexpectedBuildFailure
import org.junit.Rule
import org.junit.rules.TemporaryFolder

Expand Down Expand Up @@ -239,14 +240,32 @@ gitPublish {
working.branch.list()*.name == ['gh-pages']
}

def 'when no git publish tasks are run, build completes successfully'() {
given:
buildFile << '''\
plugins {
id 'org.ajoberstar.git-publish'
}
task hello {
doLast {
println 'Hello!'
}
}
'''
when:
build('hello')
then:
notThrown(UnexpectedBuildFailure)
}

private BuildResult build() {
private BuildResult build(String... args = ['gitPublishPush', '--stacktrace']) {
return GradleRunner.create()
.withGradleVersion(System.properties['compat.gradle.version'])
.withPluginClasspath()
.withProjectDir(projectDir)
.forwardOutput()
.withArguments('gitPublishPush', '--stacktrace')
.withArguments(args)
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public void apply(Project project) {
// always close the repo at the end of the build
project.getGradle().buildFinished(result -> {
project.getLogger().info("Closing Git publish repo: {}", extension.getRepoDir().get());
reset.getGrgit().get().close();
if (reset.getGrgit().isPresent()) {
reset.getGrgit().get().close();
}
});
}

Expand Down

0 comments on commit af6ec70

Please sign in to comment.