-
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 config file support for tag options
- Loading branch information
1 parent
6fb89a9
commit 3e069bb
Showing
6 changed files
with
86 additions
and
32 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/AlwaysLeftParent.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,13 @@ | ||
package com.zegreatrob.tools.digger.core | ||
|
||
import com.zegreatrob.tools.adapter.git.CommitRef | ||
|
||
fun List<CommitRef>.alwaysLeftParent() = fold(emptyList<CommitRef>()) { acc, commit -> | ||
if (acc.isEmpty()) { | ||
acc + commit | ||
} else if (commit.id == acc.last().parents.firstOrNull()) { | ||
acc + commit | ||
} else { | ||
acc | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/FindTrunkPath.kt
This file was deleted.
Oops, something went wrong.
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
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
63 changes: 63 additions & 0 deletions
63
...tagger-cli/src/jvmTest/kotlin/com/zegreatrob/tools/tagger/cli/TagCommandConfigFileTest.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,63 @@ | ||
@file:OptIn(ExperimentalSerializationApi::class) | ||
|
||
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 kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.serialization.json.encodeToStream | ||
import org.junit.jupiter.api.io.TempDir | ||
import java.io.File | ||
import kotlin.test.BeforeTest | ||
|
||
class TagCommandConfigFileTest : TagTestSpec { | ||
|
||
@field:TempDir | ||
override lateinit var projectDir: File | ||
|
||
override val addFileNames: Set<String> = emptySet() | ||
private lateinit var arguments: List<String> | ||
|
||
@BeforeTest | ||
fun setup() { | ||
arguments = listOf("-q", "tag") | ||
} | ||
|
||
override fun configureWithDefaults() { | ||
val config = TaggerConfig(releaseBranch = "master") | ||
Json.encodeToStream(config, File(projectDir, ".tagger").outputStream()) | ||
arguments += projectDir.absolutePath | ||
} | ||
|
||
override fun configureWithOverrides( | ||
releaseBranch: String?, | ||
userName: String?, | ||
userEmail: String?, | ||
warningsAsErrors: Boolean?, | ||
) { | ||
var config = TaggerConfig() | ||
releaseBranch?.let { config = config.copy(releaseBranch = releaseBranch) } | ||
userName?.let { config = config.copy(userName = userName) } | ||
userEmail?.let { config = config.copy(userEmail = userEmail) } | ||
warningsAsErrors?.let { config = config.copy(warningsAsErrors = warningsAsErrors) } | ||
Json.encodeToStream(config, File(projectDir, ".tagger").outputStream()) | ||
|
||
arguments += projectDir.absolutePath | ||
} | ||
|
||
override fun execute(version: String): TestResult { | ||
arguments += "--version=$version" | ||
val test = cli() | ||
.test(arguments, envvars = mapOf("PWD" to projectDir.absolutePath)) | ||
return if (test.statusCode == 0) { | ||
test | ||
.output | ||
.trim() | ||
.let { TestResult.Success(it) } | ||
} else { | ||
TestResult.Failure(test.output.trim()) | ||
} | ||
} | ||
} |