diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 148fdd24..d4b7accb 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/AllContributionCommits.kt b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/AllContributionCommits.kt
index 1d8cc1c8..a46f1a9f 100644
--- a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/AllContributionCommits.kt
+++ b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/AllContributionCommits.kt
@@ -30,7 +30,6 @@ fun GitAdapter.sortIntoTagSets(
}
}.filter { it.second.isNotEmpty() }
-private fun List.tagPairs(): List> =
- listOf(Pair(null, firstOrNull())) + mapIndexed { index, commitRef ->
- commitRef to getOrNull(index + 1)
- }
+private fun List.tagPairs(): List> = listOf(Pair(null, firstOrNull())) + mapIndexed { index, commitRef ->
+ commitRef to getOrNull(index + 1)
+}
diff --git a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/Contribution.kt b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/Contribution.kt
index b710d103..2bca1b72 100644
--- a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/Contribution.kt
+++ b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/Contribution.kt
@@ -44,10 +44,9 @@ private fun mergedStoryIds(messageDigResults: List) = me
}
}
-private fun CommitRef.commitInspectionResult(digResult: MessageDigResult) =
- CommitInspectionResult(
- storyId = digResult.storyId,
- ease = digResult.ease,
- authors = listOf(committerEmail, authorEmail) + digResult.coauthors,
- semver = digResult.semver,
- )
+private fun CommitRef.commitInspectionResult(digResult: MessageDigResult) = CommitInspectionResult(
+ storyId = digResult.storyId,
+ ease = digResult.ease,
+ authors = listOf(committerEmail, authorEmail) + digResult.coauthors,
+ semver = digResult.semver,
+)
diff --git a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/DiggerCore.kt b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/DiggerCore.kt
index cb959a4b..64ae1386 100644
--- a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/DiggerCore.kt
+++ b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/DiggerCore.kt
@@ -11,19 +11,18 @@ class DiggerCore(
) {
private fun tagRefs() = gitWrapper.listTags().filter { tagRegex.matches(it.name) }
- fun currentContributionData() =
- with(gitWrapper) {
- val (currentTag, previousTag) = currentRelevantTags(
- headCommitId = headCommitId(),
- lastTwoTags = tagRefs().take(2),
+ fun currentContributionData() = with(gitWrapper) {
+ val (currentTag, previousTag) = currentRelevantTags(
+ headCommitId = headCommitId(),
+ lastTwoTags = tagRefs().take(2),
+ )
+ messageDigger.contribution(currentContributionCommits(previousTag))
+ .copy(
+ label = label,
+ tagName = currentTag?.name,
+ tagDateTime = currentTag?.dateTime,
)
- messageDigger.contribution(currentContributionCommits(previousTag))
- .copy(
- label = label,
- tagName = currentTag?.name,
- tagDateTime = currentTag?.dateTime,
- )
- }
+ }
private fun currentRelevantTags(
headCommitId: String,
diff --git a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/MessageDigger.kt b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/MessageDigger.kt
index 37b3f38c..930949fd 100644
--- a/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/MessageDigger.kt
+++ b/tools/digger-core/src/commonMain/kotlin/com/zegreatrob/tools/digger/core/MessageDigger.kt
@@ -62,25 +62,22 @@ private fun Regex.cleaned(): String {
}
}
-private fun Sequence.messageDigResult() =
- MessageDigResult(
- coauthors = mapNotNull { it.groups["coAuthors"]?.value }.toList(),
- semver = mapNotNull { getSemver(it) }.maxOrNull(),
- storyId = firstNotNullOfOrNull { it.groups["storyId"] }?.value,
- ease = firstNotNullOfOrNull { it.groups["ease"] }?.value?.toIntOrNull(),
- )
+private fun Sequence.messageDigResult() = MessageDigResult(
+ coauthors = mapNotNull { it.groups["coAuthors"]?.value }.toList(),
+ semver = mapNotNull { getSemver(it) }.maxOrNull(),
+ storyId = firstNotNullOfOrNull { it.groups["storyId"] }?.value,
+ ease = firstNotNullOfOrNull { it.groups["ease"] }?.value?.toIntOrNull(),
+)
-private fun getSemver(it: MatchResult) =
- when {
- it.groupMatches("major") -> SemverType.Major
- it.groupMatches("minor") -> SemverType.Minor
- it.groupMatches("patch") -> SemverType.Patch
- it.groupMatches("none") -> SemverType.None
- else -> null
- }
+private fun getSemver(it: MatchResult) = when {
+ it.groupMatches("major") -> SemverType.Major
+ it.groupMatches("minor") -> SemverType.Minor
+ it.groupMatches("patch") -> SemverType.Patch
+ it.groupMatches("none") -> SemverType.None
+ else -> null
+}
-private fun MatchResult.groupMatches(groupName: String) =
- runCatching { this@groupMatches.groups[groupName] }
- .getOrNull() != null
+private fun MatchResult.groupMatches(groupName: String) = runCatching { this@groupMatches.groups[groupName] }
+ .getOrNull() != null
fun List.highestPrioritySemver() = maxOrNull()
diff --git a/tools/digger-json/src/commonMain/kotlin/com/zegreatrob/tools/digger/json/ContributionDataJson.kt b/tools/digger-json/src/commonMain/kotlin/com/zegreatrob/tools/digger/json/ContributionDataJson.kt
index d07407ee..14a00dee 100644
--- a/tools/digger-json/src/commonMain/kotlin/com/zegreatrob/tools/digger/json/ContributionDataJson.kt
+++ b/tools/digger-json/src/commonMain/kotlin/com/zegreatrob/tools/digger/json/ContributionDataJson.kt
@@ -32,30 +32,27 @@ object ContributionParser {
ignoreUnknownKeys = true
}
- fun parseContributions(jsonString: String) =
- json.decodeFromString>(jsonString)
- .map(ContributionJson::toModel)
+ fun parseContributions(jsonString: String) = json.decodeFromString>(jsonString)
+ .map(ContributionJson::toModel)
- fun parseContribution(jsonString: String) =
- json.decodeFromString(jsonString)
- ?.toModel()
+ fun parseContribution(jsonString: String) = json.decodeFromString(jsonString)
+ ?.toModel()
}
-private fun Contribution.toJsonModel() =
- ContributionJson(
- lastCommit = lastCommit,
- firstCommit = firstCommit,
- authors = authors,
- dateTime = dateTime,
- firstCommitDateTime = firstCommitDateTime,
- ease = ease,
- storyId = storyId,
- semver = semver,
- label = label,
- tagName = tagName,
- tagDateTime = tagDateTime,
- commitCount = commitCount,
- )
+private fun Contribution.toJsonModel() = ContributionJson(
+ lastCommit = lastCommit,
+ firstCommit = firstCommit,
+ authors = authors,
+ dateTime = dateTime,
+ firstCommitDateTime = firstCommitDateTime,
+ ease = ease,
+ storyId = storyId,
+ semver = semver,
+ label = label,
+ tagName = tagName,
+ tagDateTime = tagDateTime,
+ commitCount = commitCount,
+)
private fun ContributionJson.toModel() = Contribution(
lastCommit = lastCommit,
diff --git a/tools/digger-json/src/commonTest/kotlin/com/zegreatrob/tools/digger/json/ContributionParserTest.kt b/tools/digger-json/src/commonTest/kotlin/com/zegreatrob/tools/digger/json/ContributionParserTest.kt
index 2ede0eb1..d8966915 100644
--- a/tools/digger-json/src/commonTest/kotlin/com/zegreatrob/tools/digger/json/ContributionParserTest.kt
+++ b/tools/digger-json/src/commonTest/kotlin/com/zegreatrob/tools/digger/json/ContributionParserTest.kt
@@ -82,23 +82,22 @@ class ContributionParserTest {
assertEquals(contributions, loaded)
}
- private fun stubContribution() =
- Contribution(
- lastCommit = "${uuid4()}",
- firstCommit = "${uuid4()}",
- authors = listOf("${uuid4()}"),
- dateTime =
- randomInstant(),
- firstCommitDateTime =
- randomInstant(),
- ease = Random.nextInt(),
- storyId = "${uuid4()}",
- semver = "${uuid4()}",
- label = "${uuid4()}",
- tagDateTime = randomInstant(),
- tagName = "${uuid4()}",
- commitCount = Random.nextInt(10),
- )
+ private fun stubContribution() = Contribution(
+ lastCommit = "${uuid4()}",
+ firstCommit = "${uuid4()}",
+ authors = listOf("${uuid4()}"),
+ dateTime =
+ randomInstant(),
+ firstCommitDateTime =
+ randomInstant(),
+ ease = Random.nextInt(),
+ storyId = "${uuid4()}",
+ semver = "${uuid4()}",
+ label = "${uuid4()}",
+ tagDateTime = randomInstant(),
+ tagName = "${uuid4()}",
+ commitCount = Random.nextInt(10),
+ )
private fun randomInstant() = Instant.fromEpochMilliseconds(
epochMilliseconds =
diff --git a/tools/git-adapter/src/commonMain/kotlin/com/zegreatrob/tools/adapter/git/GitAdapter.kt b/tools/git-adapter/src/commonMain/kotlin/com/zegreatrob/tools/adapter/git/GitAdapter.kt
index 3219ad6c..4ead5008 100644
--- a/tools/git-adapter/src/commonMain/kotlin/com/zegreatrob/tools/adapter/git/GitAdapter.kt
+++ b/tools/git-adapter/src/commonMain/kotlin/com/zegreatrob/tools/adapter/git/GitAdapter.kt
@@ -13,8 +13,7 @@ class GitAdapter(private val workingDirectory: String, private val env: Map, env: Map = emptyMap()) =
- runProcess(args, workingDirectory, env.plus(this.env))
+ private fun runProcess(args: List, env: Map = emptyMap()) = runProcess(args, workingDirectory, env.plus(this.env))
fun newAnnotatedTag(name: String, ref: String, userName: String?, userEmail: String?) {
runProcess(
@@ -44,8 +43,7 @@ class GitAdapter(private val workingDirectory: String, private val env: Map.findByPrefix(prefix: String) =
- find { it.startsWith(prefix) }?.substring(prefix.length)
+ private fun List.findByPrefix(prefix: String) = find { it.startsWith(prefix) }?.substring(prefix.length)
fun describe(abbrev: Int): String? = runCatching {
runProcess(listOf("git", "describe", "--abbrev=$abbrev"))
diff --git a/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/ChangeType.kt b/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/ChangeType.kt
index 67146604..79a85ca4 100644
--- a/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/ChangeType.kt
+++ b/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/ChangeType.kt
@@ -51,12 +51,11 @@ private fun findAppropriateIncrement(
previousTag: String,
implicitPatch: Boolean,
minorRegex: VersionRegex,
-): ChangeType? =
- gitAdapter.logWithRange("HEAD", "^$previousTag")
- .also { if (it.isEmpty()) return null }
- .map { it.changeType(minorRegex) ?: if (implicitPatch) ChangeType.Patch else null }
- .fold(null, ::highestPriority)
- ?: if (implicitPatch) ChangeType.Patch else ChangeType.None
+): ChangeType? = gitAdapter.logWithRange("HEAD", "^$previousTag")
+ .also { if (it.isEmpty()) return null }
+ .map { it.changeType(minorRegex) ?: if (implicitPatch) ChangeType.Patch else null }
+ .fold(null, ::highestPriority)
+ ?: if (implicitPatch) ChangeType.Patch else ChangeType.None
private fun highestPriority(
left: ChangeType?,
@@ -127,25 +126,23 @@ enum class SnapshotReason {
fun reasonIsValid(check: StatusCheck): Boolean = check.exists()
}
-fun TaggerCore.tagReport() =
- adapter.listTags()
- .groupBy { tag ->
- "${tag.dateTime.toLocalDateTime(TimeZone.currentSystemDefault()).year} Week ${tag.weekNumber()}"
- }
- .toList()
- .sortedBy { (key) -> key }
- .joinToString("\n") { (key, value) ->
- "$key has ${value.size} tags [${value.joinToString { tag -> tag.name }}]"
- }
+fun TaggerCore.tagReport() = adapter.listTags()
+ .groupBy { tag ->
+ "${tag.dateTime.toLocalDateTime(TimeZone.currentSystemDefault()).year} Week ${tag.weekNumber()}"
+ }
+ .toList()
+ .sortedBy { (key) -> key }
+ .joinToString("\n") { (key, value) ->
+ "$key has ${value.size} tags [${value.joinToString { tag -> tag.name }}]"
+ }
-private fun TagRef.weekNumber() =
- "${dateTime.toLocalDateTime(TimeZone.currentSystemDefault()).dayOfYear / 7}".let {
- if (it.length == 1) {
- "0$it"
- } else {
- it
- }
+private fun TagRef.weekNumber() = "${dateTime.toLocalDateTime(TimeZone.currentSystemDefault()).dayOfYear / 7}".let {
+ if (it.length == 1) {
+ "0$it"
+ } else {
+ it
}
+}
fun VersionRegex.changeType(message: String): ChangeType? = when {
unified?.containsMatchIn(message) == true -> findMatchType(message, unified)
@@ -170,6 +167,5 @@ private fun findMatchType(
}
}
-private fun MatchGroupCollection?.groupExists(groupName: String): Boolean =
- runCatching { this?.get(groupName) != null }
- .getOrDefault(false)
+private fun MatchGroupCollection?.groupExists(groupName: String): Boolean = runCatching { this?.get(groupName) != null }
+ .getOrDefault(false)
diff --git a/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/TagErrors.kt b/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/TagErrors.kt
index f15ddca9..d168978c 100644
--- a/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/TagErrors.kt
+++ b/tools/tagger-core/src/commonMain/kotlin/com/zegreatrob/tools/tagger/core/TagErrors.kt
@@ -7,6 +7,5 @@ object TagErrors {
const val BEING_SNAPSHOT = "being snapshot"
fun alreadyTagged(headTag: String?) = "already tagged $headTag"
- fun skipMessageNotOnReleaseBranch(releaseBranch: String?, headBranch: String) =
- "not on release branch $releaseBranch - branch was $headBranch"
+ fun skipMessageNotOnReleaseBranch(releaseBranch: String?, headBranch: String) = "not on release branch $releaseBranch - branch was $headBranch"
}
diff --git a/tools/tagger-plugin/src/main/kotlin/com/zegreatrob/tools/tagger/TaggerExtension.kt b/tools/tagger-plugin/src/main/kotlin/com/zegreatrob/tools/tagger/TaggerExtension.kt
index 2264a505..ae6af42d 100644
--- a/tools/tagger-plugin/src/main/kotlin/com/zegreatrob/tools/tagger/TaggerExtension.kt
+++ b/tools/tagger-plugin/src/main/kotlin/com/zegreatrob/tools/tagger/TaggerExtension.kt
@@ -64,14 +64,13 @@ open class TaggerExtension(
).version
}
- private fun versionRegex() =
- VersionRegex(
- none = noneRegex.get(),
- patch = patchRegex.get(),
- minor = minorRegex.get(),
- major = majorRegex.get(),
- unified = versionRegex.orNull?.also { it.validateVersionRegex() },
- )
+ private fun versionRegex() = VersionRegex(
+ none = noneRegex.get(),
+ patch = patchRegex.get(),
+ minor = minorRegex.get(),
+ major = majorRegex.get(),
+ unified = versionRegex.orNull?.also { it.validateVersionRegex() },
+ )
}
private fun Regex.validateVersionRegex() {
diff --git a/tools/tagger-test/src/commonMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt b/tools/tagger-test/src/commonMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt
index cacc09c7..55085c99 100644
--- a/tools/tagger-test/src/commonMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt
+++ b/tools/tagger-test/src/commonMain/kotlin/com/zegreatrob/tools/tagger/CalculateVersionTestSpec.kt
@@ -64,11 +64,10 @@ interface CalculateVersionTestSpec {
}
fun execute(): TestResult
- fun runCalculateVersionSuccessfully(): String =
- when (val result = execute()) {
- is TestResult.Success -> result.message
- is TestResult.Failure -> fail("Expected success but got ${result.reason}")
- }
+ fun runCalculateVersionSuccessfully(): String = when (val result = execute()) {
+ is TestResult.Success -> result.message
+ is TestResult.Failure -> fail("Expected success but got ${result.reason}")
+ }
@Test
fun calculatingVersionWithNoTagsProducesZeroVersion() {