diff --git a/grgit-core/gradle.lockfile b/grgit-core/gradle.lockfile index 5aa7501f..4314e89b 100644 --- a/grgit-core/gradle.lockfile +++ b/grgit-core/gradle.lockfile @@ -7,7 +7,7 @@ net.bytebuddy:byte-buddy:1.12.10=testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.23.1=testCompileClasspath,testRuntimeClasspath org.codehaus.groovy:groovy:3.0.12=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.eclipse.jgit:org.eclipse.jgit:6.2.0.202206071550-r=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest:2.2=testCompileClasspath,testRuntimeClasspath org.jetbrains:annotations:20.1.0=testCompileClasspath,testRuntimeClasspath org.junit.jupiter:junit-jupiter-api:5.9.0=testCompileClasspath,testRuntimeClasspath diff --git a/grgit-core/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy b/grgit-core/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy index 565719f3..74cdbd6e 100644 --- a/grgit-core/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy +++ b/grgit-core/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy @@ -67,6 +67,11 @@ class CloneOp implements Callable { */ String refToCheckout + /** + * The depth of the clone. Defaults to full history. + */ + Integer depth = null + /** * The username and credentials to use when checking out the * repository and for subsequent remote operations on the @@ -89,6 +94,9 @@ class CloneOp implements Callable { cmd.remote = remote cmd.bare = bare cmd.noCheckout = !checkout + if (depth != null) { + cmd.depth = depth + } if (refToCheckout) { cmd.branch = refToCheckout } if (all) { cmd.cloneAllBranches = all } if (!branches.isEmpty()) cmd.branchesToClone = branches diff --git a/grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy b/grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy index 52936645..787213df 100644 --- a/grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy +++ b/grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy @@ -145,6 +145,15 @@ class CloneOpSpec extends MultiGitOpSpec { GitTestUtil.branches(grgit).findAll(localBranchesFilter).collect(lastName) == ['master'] } + def 'clone with all false and 1 depth'() { + when: + def grgit = Grgit.clone(dir: repoDir, uri: remoteUri, all: false, depth: 1) + then: + grgit.head().id == remoteGrgit.resolve.toCommit('master').id + grgit.head().parentIds.isEmpty() + GitTestUtil.branches(grgit).findAll(localBranchesFilter).collect(lastName) == ['master'] + } + def 'cloned repo can be deleted'() { given: def grgit = Grgit.clone(dir: repoDir, uri: remoteUri, refToCheckout: 'refs/heads/branch2') diff --git a/grgit-gradle/gradle.lockfile b/grgit-gradle/gradle.lockfile index 519da633..f4b24c5e 100644 --- a/grgit-gradle/gradle.lockfile +++ b/grgit-gradle/gradle.lockfile @@ -7,7 +7,7 @@ net.bytebuddy:byte-buddy:1.11.0=compatTestCompileClasspath,compatTestRuntimeClas org.apiguardian:apiguardian-api:1.1.0=compatTestCompileClasspath,compatTestRuntimeClasspath org.assertj:assertj-core:3.16.1=compatTestCompileClasspath,compatTestRuntimeClasspath org.codehaus.groovy:groovy:3.0.12=compatTestCompileClasspath,compatTestRuntimeClasspath -org.eclipse.jgit:org.eclipse.jgit:6.2.0.202206071550-r=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest:2.2=compatTestCompileClasspath,compatTestRuntimeClasspath org.jetbrains:annotations:20.1.0=compatTestCompileClasspath,compatTestRuntimeClasspath org.junit.platform:junit-platform-commons:1.7.2=compatTestCompileClasspath,compatTestRuntimeClasspath