Skip to content

Commit

Permalink
Merge pull request #111 from ajoberstar/no-grgit
Browse files Browse the repository at this point in the history
major: Use git cli instead of grgit
  • Loading branch information
ajoberstar authored Oct 6, 2024
2 parents 61a2fed + 67f2158 commit 381a2d1
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 319 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
17
21
- name: Set committer info (for tests)
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "noreply@github.com"
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
Expand Down
7 changes: 1 addition & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ java {
}

dependencies {
// grgit
api("org.ajoberstar.grgit:grgit-core:[5.0,6.0[")
api("org.ajoberstar.grgit:grgit-gradle:[5.0,6.0[")
compatTestImplementation("org.ajoberstar.grgit:grgit-core:[5.0,6.0[")

// testing
compatTestImplementation(gradleTestKit())
compatTestImplementation("org.spockframework:spock-core:2.3-groovy-3.0")
compatTestImplementation("org.ajoberstar.grgit:grgit-core:[5.0,6.0[")
}

tasks.named<Jar>("jar") {
Expand Down
15 changes: 7 additions & 8 deletions gradle.lockfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.googlecode.javaewah:JavaEWAH:1.2.3=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
commons-codec:commons-codec:1.16.0=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ajoberstar.grgit:grgit-core:5.2.2=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ajoberstar.grgit:grgit-gradle:5.2.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.googlecode.javaewah:JavaEWAH:1.2.3=compatTestCompileClasspath,compatTestRuntimeClasspath
commons-codec:commons-codec:1.17.0=compatTestCompileClasspath,compatTestRuntimeClasspath
org.ajoberstar.grgit:grgit-core:5.3.0=compatTestCompileClasspath,compatTestRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=compatTestCompileClasspath
org.codehaus.groovy:groovy:3.0.20=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.groovy:groovy:3.0.22=compatTestCompileClasspath,compatTestRuntimeClasspath
org.eclipse.jgit:org.eclipse.jgit:6.10.0.202406032230-r=compatTestCompileClasspath,compatTestRuntimeClasspath
org.hamcrest:hamcrest:2.2=compatTestCompileClasspath,compatTestRuntimeClasspath
org.junit.platform:junit-platform-commons:1.9.0=compatTestCompileClasspath,compatTestRuntimeClasspath
org.junit.platform:junit-platform-engine:1.9.0=compatTestCompileClasspath,compatTestRuntimeClasspath
org.junit:junit-bom:5.9.0=compatTestCompileClasspath,compatTestRuntimeClasspath
org.opentest4j:opentest4j:1.2.0=compatTestCompileClasspath,compatTestRuntimeClasspath
org.slf4j:slf4j-api:1.7.36=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.slf4j:slf4j-api:1.7.36=compatTestCompileClasspath,compatTestRuntimeClasspath
org.spockframework:spock-core:2.3-groovy-3.0=compatTestCompileClasspath,compatTestRuntimeClasspath
empty=annotationProcessor,compatTestAnnotationProcessor,signatures,testAnnotationProcessor
empty=annotationProcessor,compatTestAnnotationProcessor,compileClasspath,runtimeClasspath,signatures,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.ajoberstar.gradle.git.publish

import spock.lang.IgnoreIf
import spock.lang.Specification
import spock.lang.TempDir

import org.ajoberstar.grgit.Grgit
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.gradle.testkit.runner.UnexpectedBuildFailure
import spock.lang.Specification
import spock.lang.TempDir

class BaseCompatTest extends Specification {
@TempDir File tempDir
Expand All @@ -25,7 +23,7 @@ class BaseCompatTest extends Specification {

remoteFile('master.txt') << 'contents here'
remote.add(patterns: ['.'])
remote.commit(message: 'first commit')
remote.commit(message: 'first commit', sign: false)

// handle different init branches to keep existing tests the same
if (remote.branch.current().name != 'master') {
Expand All @@ -37,7 +35,7 @@ class BaseCompatTest extends Specification {
remoteFile('index.md') << '# This Page is Awesome!'
remoteFile('1.0.0/index.md') << '# Version 1.0.0 is the Best!'
remote.add(patterns: ['.'])
remote.commit(message: 'first pages commit')
remote.commit(message: 'first pages commit', sign: false)

remote.checkout(branch: 'master')
}
Expand All @@ -52,7 +50,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'my-pages'
contents.from 'src'
}
Expand All @@ -77,7 +75,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
}
Expand All @@ -97,7 +95,7 @@ gitPublish {
remote.checkout(branch: 'gh-pages')
remoteFile('index.md') << 'And has great content'
remote.add(patterns: ['.'])
remote.commit(message: 'second pages commit')
remote.commit(message: 'second pages commit', sign: false)
remote.checkout(branch: 'master')

projectFile('src/content.txt') << 'published content here'
Expand All @@ -108,7 +106,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
fetchDepth = 1
contents.from 'src'
Expand All @@ -130,14 +128,14 @@ gitPublish {
def 'reset pulls from reference repo if available before pulling from remote'() {
given:
def referenceDir = new File(tempDir, 'reference')
def reference = Grgit.clone(dir: referenceDir, uri: remote.repository.rootDir.toURI())
def reference = Grgit.clone(dir: referenceDir, uri: repoPath(remote))
reference.checkout(branch: 'gh-pages', createBranch: true)
// add a file that will get fetched but not pushed
def refFile = new File(reference.repository.rootDir, 'src/newFile.txt')
refFile.parentFile.mkdirs()
refFile.text = 'Some content'
reference.add(patterns: ['.'])
reference.commit(message: 'This wont get pushed')
reference.commit(message: 'This wont get pushed', sign: false)

projectFile('src/content.txt') << 'published content here'

Expand All @@ -147,8 +145,8 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
referenceRepoUri = '${reference.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
referenceRepoUri = '${repoPath(reference)}'
branch = 'gh-pages'
contents.from 'src'
}
Expand All @@ -159,7 +157,7 @@ gitPublish {
remote.checkout(branch: 'gh-pages')
then:
result.task(':gitPublishPush').outcome == TaskOutcome.SUCCESS
result.output.contains('Fetching from reference repo')
result.output.contains('gh-pages -> reference/gh-pages')
remote.log().size() == 2
remoteFile('content.txt').text == 'published content here'
!remoteFile('newFile.txt').exists()
Expand All @@ -175,7 +173,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
repoDir = file('build/this-is-custom')
branch = 'gh-pages'
contents.from 'src'
Expand All @@ -197,7 +195,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
Expand Down Expand Up @@ -229,7 +227,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents {
from('src1') {
Expand Down Expand Up @@ -263,7 +261,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
}
Expand All @@ -274,16 +272,16 @@ gitPublish {
remote.checkout(branch: 'gh-pages')
then:
result.task(':gitPublishCommit').outcome == TaskOutcome.UP_TO_DATE
result.task(':gitPublishPush').outcome == TaskOutcome.SKIPPED
result.task(':gitPublishPush').outcome == TaskOutcome.UP_TO_DATE
}

def 'existing working repo is reused if valid'() {
given:
def working = Grgit.clone(dir: "${projectDir}/build/gitPublish", uri: remote.repository.rootDir.toURI())
def working = Grgit.clone(dir: "${projectDir}/build/gitPublish", uri: repoPath(remote))
working.checkout(branch: 'master')
new File(projectDir, 'build/gitPublish/master.txt') << 'working repo was here'
working.add(patterns: ['.'])
working.commit(message: 'working repo was here')
working.commit(message: 'working repo was here', sign: false)
working.checkout(branch: 'gh-pages', startPoint: 'origin/gh-pages', createBranch: 'true')
working.close()

Expand All @@ -293,7 +291,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents {
from 'src'
Expand All @@ -320,7 +318,7 @@ gitPublish {

new File(badRemoteDir, 'master.txt') << 'bad contents here'
badRemote.add(patterns: ['.'])
badRemote.commit(message: 'bad first commit')
badRemote.commit(message: 'bad first commit', sign: false)

// handle different init branches to keep existing tests the same
if (badRemote.branch.current().name != 'master') {
Expand All @@ -339,7 +337,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
}
Expand Down Expand Up @@ -384,7 +382,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
commitMessage = "Deploy docs to gh-pages (\${project.name})"
Expand All @@ -398,7 +396,7 @@ gitPublish {
result.task(':gitPublishPush').outcome == TaskOutcome.SUCCESS
remote.log().size() == 2
remoteFile('content.txt').text == 'published content here'
remote.head().fullMessage == "Deploy docs to gh-pages (${projectFile('.').canonicalFile.name})"
remote.head().fullMessage == "Deploy docs to gh-pages (${projectFile('.').canonicalFile.name})\n"
}

def 'can activate signing'() {
Expand All @@ -415,7 +413,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
sign = true
Expand All @@ -425,7 +423,7 @@ gitPublish {
def result = buildAndFail()

then:
result.output.contains("org.eclipse.jgit.api.errors.ServiceUnavailableException")
result.output.contains("gpg: signing failed: No secret key")
}

def 'can deactivate signing'() {
Expand All @@ -442,7 +440,7 @@ plugins {
}
gitPublish {
repoUri = '${remote.repository.rootDir.toURI()}'
repoUri = '${repoPath(remote)}'
branch = 'gh-pages'
contents.from 'src'
sign = false
Expand All @@ -455,11 +453,11 @@ gitPublish {
result.task(':gitPublishPush').outcome == TaskOutcome.SUCCESS
}

private BuildResult build(String... args = ['gitPublishPush', '--stacktrace', '--info', '--configuration-cache']) {
private BuildResult build(String... args = ['gitPublishPush', '--stacktrace', '--configuration-cache']) {
return runner(args).build()
}

private BuildResult buildAndFail(String... args = ['gitPublishPush', '--stacktrace', '--info', '--configuration-cache']) {
private BuildResult buildAndFail(String... args = ['gitPublishPush', '--stacktrace', '--configuration-cache']) {
return runner(args).buildAndFail()
}

Expand All @@ -483,4 +481,8 @@ gitPublish {
file.parentFile.mkdirs()
return file
}

private String repoPath(Grgit repo) {
return repo.repository.rootDir.toPath().toAbsolutePath().toString().replace('\\', '\\\\')
}
}
Loading

0 comments on commit 381a2d1

Please sign in to comment.