From c20f04cd7b5e13064941e30edc42688a58a1ebd1 Mon Sep 17 00:00:00 2001 From: RoB Murdock Date: Sat, 21 Sep 2024 18:08:31 -0400 Subject: [PATCH] [none] fully removing grgit from tagger tests --- tools/git-test/build.gradle.kts | 1 - tools/tagger-test/build.gradle.kts | 1 - .../tools/tagger/CalculateVersionTestSpec.kt | 34 +++---------- .../zegreatrob/tools/tagger/TagTestSpec.kt | 49 ++++++------------- 4 files changed, 22 insertions(+), 63 deletions(-) diff --git a/tools/git-test/build.gradle.kts b/tools/git-test/build.gradle.kts index 51a78f9c..9664d7f3 100644 --- a/tools/git-test/build.gradle.kts +++ b/tools/git-test/build.gradle.kts @@ -10,7 +10,6 @@ kotlin { dependencies { commonMainImplementation(platform(project(":dependency-bom"))) commonMainImplementation(project(":git-adapter")) - "jvmMainApi"(libs.org.ajoberstar.grgit.grgit.core) "jvmMainApi"(kotlin("test-junit5", embeddedKotlinVersion)) "jvmMainApi"("org.junit.jupiter:junit-jupiter-api") "jvmMainApi"("org.junit.jupiter:junit-jupiter-engine") diff --git a/tools/tagger-test/build.gradle.kts b/tools/tagger-test/build.gradle.kts index 5f34e470..c1903e6f 100644 --- a/tools/tagger-test/build.gradle.kts +++ b/tools/tagger-test/build.gradle.kts @@ -11,7 +11,6 @@ dependencies { commonMainImplementation(platform(project(":dependency-bom"))) commonMainImplementation(project(":tagger-core")) commonMainApi(project(":git-test")) - "jvmMainApi"(libs.org.ajoberstar.grgit.grgit.core) "jvmMainApi"(kotlin("test-junit5", embeddedKotlinVersion)) "jvmMainApi"("org.junit.jupiter:junit-jupiter-api") "jvmMainApi"("org.junit.jupiter:junit-jupiter-engine") diff --git a/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt b/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt index c510a749..d96d94cf 100644 --- a/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt +++ b/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt @@ -1,12 +1,8 @@ package com.zegreatrob.tools.tagger import com.zegreatrob.tools.adapter.git.GitAdapter +import com.zegreatrob.tools.test.git.addCommitWithMessage import com.zegreatrob.tools.test.git.initializeGitRepo -import org.ajoberstar.grgit.Grgit -import org.ajoberstar.grgit.operation.AddOp -import org.ajoberstar.grgit.operation.CommitOp -import org.ajoberstar.grgit.operation.RemoteAddOp -import org.ajoberstar.grgit.operation.TagAddOp import java.io.File import kotlin.test.Test import kotlin.test.assertContains @@ -63,29 +59,11 @@ interface CalculateVersionTestSpec { val gitAdapter = GitAdapter(projectDir.absolutePath) gitAdapter.init() gitAdapter.config("commit.gpgsign", "false") - val grgit = Grgit.open(mapOf("dir" to projectDir.absolutePath)) - grgit.add( - fun(it: AddOp) { - it.patterns = setOf(".") - }, - ) - grgit.commit( - fun(it: CommitOp) { - it.message = "test commit" - }, - ) - grgit.tag.add( - fun(it: TagAddOp) { - it.name = "1.0.23" - }, - ) - grgit.checkout(mapOf("branch" to "main", "createBranch" to true)) - grgit.remote.add( - fun(it: RemoteAddOp) { - it.name = "origin" - it.url = projectDir.absolutePath - }, - ) + gitAdapter.add(".") + gitAdapter.addCommitWithMessage("test commit") + gitAdapter.newAnnotatedTag("1.0.23", "HEAD", null, null) + gitAdapter.checkout("main", newBranch = true) + gitAdapter.addRemote("origin", projectDir.absolutePath) val version = runCalculateVersionSuccessfully() assertEquals("1.0.23-SNAPSHOT", version) diff --git a/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/TagTestSpec.kt b/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/TagTestSpec.kt index 5a7f2361..a783333d 100644 --- a/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/TagTestSpec.kt +++ b/tools/tagger-test/src/jvmMain/kotlin/com/zegreatrob/tools/tagger/TagTestSpec.kt @@ -3,9 +3,7 @@ package com.zegreatrob.tools.tagger import com.zegreatrob.tools.adapter.git.GitAdapter import com.zegreatrob.tools.adapter.git.runProcess import com.zegreatrob.tools.tagger.core.TagErrors -import org.ajoberstar.grgit.Grgit -import org.ajoberstar.grgit.operation.CommitOp -import org.ajoberstar.grgit.operation.InitOp +import com.zegreatrob.tools.test.git.addCommitWithMessage import org.junit.jupiter.api.Assertions.assertNotEquals import java.io.File import kotlin.io.path.absolutePathString @@ -62,14 +60,11 @@ interface TagTestSpec { configureWithDefaults() val originDirectory = createTempDirectory() - val originGrgit = Grgit.init(fun InitOp.() { - this.dir = originDirectory.absolutePathString() - }) val originGitAdapter = GitAdapter(originDirectory.absolutePathString()) + originGitAdapter.init() + originGitAdapter.config("receive.denyCurrentBranch", "ignore") originGitAdapter.disableGpgSign() - originGrgit.commit(fun CommitOp.() { - this.message = "init" - }) + originGitAdapter.addCommitWithMessage("init") val gitAdapter = initializeGitRepo( listOf("init", "[patch] commit 1", "[patch] commit 2"), remoteUrl = originDirectory.absolutePathString(), @@ -100,14 +95,11 @@ interface TagTestSpec { ) val originDirectory = createTempDirectory() - val originGrgit = Grgit.init(fun InitOp.() { - this.dir = originDirectory.absolutePathString() - }) val originGitAdapter = GitAdapter(originDirectory.absolutePathString()) + originGitAdapter.init() + originGitAdapter.config("receive.denyCurrentBranch", "ignore") originGitAdapter.disableGpgSign() - originGrgit.commit(fun CommitOp.() { - this.message = "init" - }) + originGitAdapter.addCommitWithMessage("init") val gitAdapter = initializeGitRepo( listOf("init", "[patch] commit 1", "[patch] commit 2"), remoteUrl = originDirectory.absolutePathString(), @@ -126,14 +118,11 @@ interface TagTestSpec { configureWithOverrides(releaseBranch = "master", warningsAsErrors = true) val originDirectory = createTempDirectory() - val originGrgit = Grgit.init(fun InitOp.() { - this.dir = originDirectory.absolutePathString() - }) val originGitAdapter = GitAdapter(originDirectory.absolutePathString()) + originGitAdapter.init() + originGitAdapter.config("receive.denyCurrentBranch", "ignore") originGitAdapter.disableGpgSign() - originGrgit.commit(fun CommitOp.() { - this.message = "init" - }) + originGitAdapter.addCommitWithMessage("init") val gitAdapter = initializeGitRepo( listOf("init", "[patch] commit 1", "[patch] commit 2"), remoteUrl = originDirectory.absolutePathString(), @@ -154,14 +143,11 @@ interface TagTestSpec { configureWithOverrides(releaseBranch = "trunk", warningsAsErrors = true) val originDirectory = createTempDirectory() - val originGrgit = Grgit.init(fun InitOp.() { - this.dir = originDirectory.absolutePathString() - }) val originGitAdapter = GitAdapter(originDirectory.absolutePathString()) + originGitAdapter.init() + originGitAdapter.config("receive.denyCurrentBranch", "ignore") originGitAdapter.disableGpgSign() - originGrgit.commit(fun CommitOp.() { - this.message = "init" - }) + originGitAdapter.addCommitWithMessage("init") val gitAdapter = initializeGitRepo( listOf("init", "[patch] commit 1", "[patch] commit 2"), remoteUrl = originDirectory.absolutePathString(), @@ -185,14 +171,11 @@ interface TagTestSpec { configureWithOverrides(releaseBranch = "trunk", warningsAsErrors = false) val originDirectory = createTempDirectory() - val originGrgit = Grgit.init(fun InitOp.() { - this.dir = originDirectory.absolutePathString() - }) val originGitAdapter = GitAdapter(originDirectory.absolutePathString()) + originGitAdapter.init() + originGitAdapter.config("receive.denyCurrentBranch", "ignore") originGitAdapter.disableGpgSign() - originGrgit.commit(fun CommitOp.() { - this.message = "init" - }) + originGitAdapter.addCommitWithMessage("init") val gitAdapter = initializeGitRepo( listOf("init", "[patch] commit 1", "[patch] commit 2"), remoteUrl = originDirectory.absolutePathString(),