Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 61c477a

Browse files
authored
Merge pull request #386 from ajoberstar/updates
Updates
2 parents 625a6dc + 169333f commit 61c477a

File tree

15 files changed

+107
-71
lines changed

15 files changed

+107
-71
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ jobs:
77
ci:
88
runs-on: ubuntu-latest
99
env:
10-
GRADLE_OPTS: -Dorg.gradle.java.installations.fromEnv=JAVA_HOME_8_x64,JAVA_HOME_11_x64,JAVA_HOME_17_x64
10+
GRADLE_OPTS: -Dorg.gradle.java.installations.fromEnv=JAVA_HOME_11_x64,JAVA_HOME_17_x64
1111
steps:
1212
- name: Checkout repo
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
with:
1515
fetch-depth: 0
1616

17-
- name: Setup Java 11
18-
uses: actions/setup-java@v2
17+
- name: Setup Java
18+
uses: actions/setup-java@v3
1919
with:
2020
distribution: temurin
21-
java-version: 11
22-
- name: Setup Java 17
23-
uses: actions/setup-java@v2
24-
with:
25-
distribution: temurin
26-
java-version: 17
21+
java-version: |
22+
11
23+
17
2724
2825
- name: Validate Gradle Wrapper
2926
uses: gradle/wrapper-validation-action@v1
3027
- name: Setup Gradle
3128
uses: gradle/gradle-build-action@v2
3229
- name: Gradle check
3330
run: ./gradlew check --continue
31+
env:
32+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SIGNING_KEY }}
33+
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.PGP_SIGNING_PASSPHRASE }}

.github/workflows/release.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout repo
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@v3
1111
with:
1212
fetch-depth: 0
13-
- name: Setup Java 11
14-
uses: actions/setup-java@v2
15-
with:
16-
distribution: zulu
17-
java-version: 11
13+
1814
- name: Setup Java 17
19-
uses: actions/setup-java@v2
15+
uses: actions/setup-java@v3
2016
with:
21-
distribution: zulu
22-
java-version: 17
17+
distribution: temurin
18+
java-version: |
19+
11
20+
17
2321
2422
- name: Setup Gradle
2523
uses: gradle/gradle-build-action@v2

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,15 @@ plugins {
6565
id 'org.ajoberstar.grgit.service' version '<version>'
6666
}
6767
68-
tasks.register("describe", DescribeTask) {
69-
service = grgitService.service
70-
}
68+
tasks.register("describe", DescribeTask, grgitService.service)
7169
7270
class DescribeTask extends DefaultTask {
73-
@Input
74-
final Property<GrgitService> service
71+
private final Provider<GrgitService> service
7572
7673
@Inject
77-
DoStuffTask(ObjectFactory objectFactory) {
78-
this.service = objectFactory.property(GrgitService.class);
79-
usesService(this.service);
74+
DescribeTask(Provider<GrgitService> service) {
75+
this.service = service
76+
usesService(service)
8077
}
8178
8279
@TaskAction

docs/modules/ROOT/pages/grgit-clone.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ grgit-clone - Clone a repository into a new directory
1010
----
1111
Grgit.clone(dir: <path>, uri: <path or uri>, remote: <name>, all: <boolean>,
1212
bare: <boolean>, branches: <full refs>, checkout: <boolean>,
13-
refToCheckout: <name>, credentials: <credentials>)
13+
refToCheckout: <name>, depth: <integer>, credentials: <credentials>)
1414
----
1515

1616
[source, groovy]
@@ -24,6 +24,7 @@ Grgit.clone {
2424
branches = <full refs>
2525
checkout = <boolean>
2626
refToCheckout = <name>
27+
depth = <integer>
2728
credentials = <credentials>
2829
}
2930
----
@@ -48,6 +49,7 @@ bare:: (`boolean`, default `false`) Create a bare repository.
4849
branches:: (`List<String>`, `[]`) Select full refs to use with `all = false`.
4950
checkout:: (`boolean`, default `true`) Set to `false` to skip checking out a `HEAD`.
5051
refToCheckout:: (`String`, default `null`) Instead of pointing the newly created `HEAD` to the branch pointed to by the cloned repository’s `HEAD`, point to `<name>` branch instead. In a non-bare repository, this is the branch that will be checked out. This can also take tags and detaches the `HEAD` at that commit in the resulting repository.
52+
depth:: (`Integer`, default `null`) If set, does a shallow clone to the specified depth
5153
credentials:: (`Credentials`, default `null`) An instance of link:https://github.com/ajoberstar/grgit/blob/{page-component-version}/grgit-core/src/main/groovy/org/ajoberstar/grgit/Credentials.groovy[Credentials] containing username/password to be used in operations that require authentication. See xref:grgit-authentication.adoc[grgit-authentication] for preferred ways to configure this.
5254

5355
== Examples

grgit-core/gradle.lockfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ com.googlecode.javaewah:JavaEWAH:1.1.13=compileClasspath,runtimeClasspath,testCo
66
net.bytebuddy:byte-buddy:1.12.10=testCompileClasspath,testRuntimeClasspath
77
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
88
org.assertj:assertj-core:3.23.1=testCompileClasspath,testRuntimeClasspath
9-
org.codehaus.groovy:groovy:3.0.12=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
10-
org.eclipse.jgit:org.eclipse.jgit:6.2.0.202206071550-r=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9+
org.codehaus.groovy:groovy:3.0.17=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
10+
org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
1111
org.hamcrest:hamcrest:2.2=testCompileClasspath,testRuntimeClasspath
1212
org.jetbrains:annotations:20.1.0=testCompileClasspath,testRuntimeClasspath
13-
org.junit.jupiter:junit-jupiter-api:5.9.0=testCompileClasspath,testRuntimeClasspath
14-
org.junit.platform:junit-platform-commons:1.9.0=testCompileClasspath,testRuntimeClasspath
15-
org.junit.platform:junit-platform-engine:1.9.0=testCompileClasspath,testRuntimeClasspath
16-
org.junit.platform:junit-platform-launcher:1.9.0=testCompileClasspath,testRuntimeClasspath
17-
org.junit.platform:junit-platform-testkit:1.9.0=testCompileClasspath,testRuntimeClasspath
18-
org.junit:junit-bom:5.9.0=testCompileClasspath,testRuntimeClasspath
13+
org.junit.jupiter:junit-jupiter-api:5.9.2=testCompileClasspath,testRuntimeClasspath
14+
org.junit.platform:junit-platform-commons:1.9.2=testCompileClasspath,testRuntimeClasspath
15+
org.junit.platform:junit-platform-engine:1.9.2=testCompileClasspath,testRuntimeClasspath
16+
org.junit.platform:junit-platform-launcher:1.9.2=testCompileClasspath,testRuntimeClasspath
17+
org.junit.platform:junit-platform-testkit:1.9.2=testCompileClasspath,testRuntimeClasspath
18+
org.junit:junit-bom:5.9.2=testCompileClasspath,testRuntimeClasspath
1919
org.objenesis:objenesis:3.2=testCompileClasspath,testRuntimeClasspath
2020
org.opentest4j:opentest4j:1.2.0=testCompileClasspath,testRuntimeClasspath
2121
org.ow2.asm:asm:9.1=testCompileClasspath,testRuntimeClasspath
2222
org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath
23-
org.slf4j:slf4j-api:2.0.0-beta1=testCompileClasspath,testRuntimeClasspath
24-
org.slf4j:slf4j-simple:2.0.0-beta1=testRuntimeClasspath
23+
org.slf4j:slf4j-api:2.0.7=testCompileClasspath,testRuntimeClasspath
24+
org.slf4j:slf4j-simple:2.0.7=testRuntimeClasspath
2525
org.spockframework:spock-core:2.0-groovy-3.0=testCompileClasspath,testRuntimeClasspath
2626
empty=

grgit-core/src/main/groovy/org/ajoberstar/grgit/operation/CloneOp.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class CloneOp implements Callable<Grgit> {
6767
*/
6868
String refToCheckout
6969

70+
/**
71+
* The depth of the clone. Defaults to full history.
72+
*/
73+
Integer depth = null
74+
7075
/**
7176
* The username and credentials to use when checking out the
7277
* repository and for subsequent remote operations on the
@@ -89,6 +94,9 @@ class CloneOp implements Callable<Grgit> {
8994
cmd.remote = remote
9095
cmd.bare = bare
9196
cmd.noCheckout = !checkout
97+
if (depth != null) {
98+
cmd.depth = depth
99+
}
92100
if (refToCheckout) { cmd.branch = refToCheckout }
93101
if (all) { cmd.cloneAllBranches = all }
94102
if (!branches.isEmpty()) cmd.branchesToClone = branches

grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/CloneOpSpec.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ class CloneOpSpec extends MultiGitOpSpec {
145145
GitTestUtil.branches(grgit).findAll(localBranchesFilter).collect(lastName) == ['master']
146146
}
147147

148+
def 'clone with all false and 1 depth'() {
149+
when:
150+
def grgit = Grgit.clone(dir: repoDir, uri: remoteUri, all: false, depth: 1)
151+
then:
152+
grgit.head().id == remoteGrgit.resolve.toCommit('master').id
153+
grgit.head().parentIds.isEmpty()
154+
GitTestUtil.branches(grgit).findAll(localBranchesFilter).collect(lastName) == ['master']
155+
}
156+
148157
def 'cloned repo can be deleted'() {
149158
given:
150159
def grgit = Grgit.clone(dir: repoDir, uri: remoteUri, refToCheckout: 'refs/heads/branch2')

grgit-core/src/test/groovy/org/ajoberstar/grgit/operation/LogOpSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class LogOpSpec extends SimpleGitOpSpec {
4747

4848
def 'log with no arguments returns all commits'() {
4949
expect:
50-
grgit.log() == [5, 4, 3, 1, 2, 0].collect(intToCommit)
50+
grgit.log() in [[5, 4, 3, 2, 1, 0], [5, 4, 3, 1, 2, 0]]*.collect(intToCommit)
5151
}
5252

5353
def 'log with max commits returns that number of commits'() {
@@ -57,7 +57,7 @@ class LogOpSpec extends SimpleGitOpSpec {
5757

5858
def 'log with skip commits does not return the first x commits'() {
5959
expect:
60-
grgit.log(skipCommits:2) == [3, 1, 2, 0].collect(intToCommit)
60+
grgit.log(skipCommits:2) in [[3, 2, 1, 0], [3, 1, 2, 0]]*.collect(intToCommit)
6161
}
6262

6363
def 'log with range returns only the commits in that range'() {

grgit-gradle/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ gradlePlugin {
7979
}
8080
}
8181
}
82+
83+
tasks.withType<Test> {
84+
if (name.startsWith("compatTest")) {
85+
dependsOn(tasks.named("publishToMavenLocal"))
86+
dependsOn(project(":grgit-core").tasks.named("publishToMavenLocal"))
87+
systemProperty("compat.plugin.version", project.version.toString())
88+
}
89+
}

grgit-gradle/gradle.lockfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ com.googlecode.javaewah:JavaEWAH:1.1.13=compatTestCompileClasspath,compatTestRun
66
net.bytebuddy:byte-buddy:1.11.0=compatTestCompileClasspath,compatTestRuntimeClasspath
77
org.apiguardian:apiguardian-api:1.1.0=compatTestCompileClasspath,compatTestRuntimeClasspath
88
org.assertj:assertj-core:3.16.1=compatTestCompileClasspath,compatTestRuntimeClasspath
9-
org.codehaus.groovy:groovy:3.0.12=compatTestCompileClasspath,compatTestRuntimeClasspath
10-
org.eclipse.jgit:org.eclipse.jgit:6.2.0.202206071550-r=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9+
org.codehaus.groovy:groovy:3.0.17=compatTestCompileClasspath,compatTestRuntimeClasspath
10+
org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
1111
org.hamcrest:hamcrest:2.2=compatTestCompileClasspath,compatTestRuntimeClasspath
1212
org.jetbrains:annotations:20.1.0=compatTestCompileClasspath,compatTestRuntimeClasspath
1313
org.junit.platform:junit-platform-commons:1.7.2=compatTestCompileClasspath,compatTestRuntimeClasspath

0 commit comments

Comments
 (0)