-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] adding tag functionality to cli
- Loading branch information
1 parent
ad22409
commit 8da26ff
Showing
7 changed files
with
78 additions
and
15 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
tools/tagger-cli/src/commonMain/kotlin/com/zegreatrob/tools/tagger/cli/Tag.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.zegreatrob.tools.tagger.cli | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.parameters.arguments.argument | ||
import com.github.ajalt.clikt.parameters.options.option | ||
import com.github.ajalt.clikt.parameters.options.required | ||
import com.zegreatrob.tools.adapter.git.GitAdapter | ||
import com.zegreatrob.tools.tagger.core.TaggerCore | ||
import com.zegreatrob.tools.tagger.core.tag | ||
|
||
class Tag : CliktCommand() { | ||
private val dir by argument("git-repo") | ||
private val releaseBranch by option().required() | ||
private val version: String by option().required() | ||
override fun run() { | ||
TaggerCore(GitAdapter(dir)) | ||
.tag(version, releaseBranch) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tools/tagger-cli/src/jvmTest/kotlin/com/zegreatrob/tools/tagger/cli/TagCommandTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.zegreatrob.tools.tagger.cli | ||
|
||
import com.github.ajalt.clikt.testing.test | ||
import com.zegreatrob.tools.tagger.TagTestSpec | ||
import com.zegreatrob.tools.tagger.TestResult | ||
import org.junit.jupiter.api.io.TempDir | ||
import java.io.File | ||
import kotlin.test.BeforeTest | ||
|
||
class TagCommandTest : TagTestSpec { | ||
|
||
@field:TempDir | ||
override lateinit var projectDir: File | ||
|
||
override val addFileNames: Set<String> = emptySet() | ||
private lateinit var arguments: List<String> | ||
|
||
@BeforeTest | ||
fun setup() { | ||
arguments = emptyList() | ||
} | ||
|
||
override fun configureWithDefaults() { | ||
arguments += "--release-branch=master" | ||
arguments += projectDir.absolutePath | ||
} | ||
|
||
override fun execute(version: String): TestResult { | ||
arguments += "--version=$version" | ||
val test = Tag() | ||
.test(arguments) | ||
return if (test.statusCode == 0) { | ||
test | ||
.output | ||
.trim() | ||
.let { TestResult.Success(it) } | ||
} else { | ||
TestResult.Failure(test.output.trim()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.io.TempDir | |
import java.io.File | ||
import kotlin.test.BeforeTest | ||
|
||
class TagAndPushFunctionalTest : TagAndPushTestSpec { | ||
class TagFunctionalTest : TagTestSpec { | ||
|
||
@field:TempDir | ||
override lateinit var projectDir: File | ||
|
@@ -36,14 +36,14 @@ class TagAndPushFunctionalTest : TagAndPushTestSpec { | |
) | ||
} | ||
|
||
override fun execute(): TestResult { | ||
override fun execute(version: String): TestResult { | ||
runProcess(listOf("git", "config", "user.email", "[email protected]"), this.projectDir.absolutePath) | ||
runProcess(listOf("git", "config", "user.name", "RoB as Test"), this.projectDir.absolutePath) | ||
|
||
val runner = GradleRunner.create() | ||
runner.forwardOutput() | ||
runner.withPluginClasspath() | ||
runner.withArguments("tag", "-Pversion=1.0.0") | ||
runner.withArguments("tag", "-Pversion=$version") | ||
runner.withProjectDir(projectDir) | ||
return try { | ||
val result = runner.build() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters