diff --git a/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy b/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy index 91198608..bee5975e 100644 --- a/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy +++ b/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy @@ -103,7 +103,7 @@ class CloneOp implements Callable { if (refToCheckout) { cmd.branch = refToCheckout } try { - cmd.call() + cmd.call().close() return Grgit.open(dir: dir, creds: credentials) } catch (GitAPIException e) { throw new GrgitException('Problem cloning repository.', e) diff --git a/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy b/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy index 0b35436f..e231580d 100644 --- a/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy +++ b/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy @@ -131,4 +131,13 @@ class CloneOpSpec extends MultiGitOpSpec { GitTestUtil.tags(grgit).collect(lastName) == ['tag1'] GitTestUtil.remotes(grgit) == ['origin'] } + + def 'cloned repo can be deleted'() { + given: + def grgit = Grgit.clone(dir: repoDir, uri: remoteUri, refToCheckout: 'refs/heads/branch2') + when: + grgit.close() + then: + assert repoDir.deleteDir() + } }