From 80e323b3267261407c7c9e383e117966c345b22e Mon Sep 17 00:00:00 2001 From: William Brawner Date: Fri, 29 Sep 2023 07:44:24 -0600 Subject: [PATCH] Rename VersionPart to ReleaseType --- .../wbrawner/releasehelper/ReleaseHelperPlugin.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt b/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt index 5209dfc..d275b79 100644 --- a/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt +++ b/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt @@ -2,7 +2,6 @@ package com.wbrawner.releasehelper import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.provider.Provider import org.gradle.api.tasks.Exec import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.provideDelegate @@ -48,7 +47,7 @@ class ReleaseHelperPlugin : Plugin { dependsOn("changelog", "getLatestTag") doLast { val latestTag: String by target.project.extra - val newVersion = latestTag.incrementVersion(VersionPart.MAJOR) + val newVersion = latestTag.incrementVersion(ReleaseType.MAJOR) target.updateVersionName(latestTag, newVersion) target.exec { commandLine = "git tag $newVersion".split(" ") @@ -60,7 +59,7 @@ class ReleaseHelperPlugin : Plugin { dependsOn("changelog", "getLatestTag") doLast { val latestTag: String by target.project.extra - val newVersion = latestTag.incrementVersion(VersionPart.MAJOR) + val newVersion = latestTag.incrementVersion(ReleaseType.MAJOR) target.updateVersionName(latestTag, newVersion) target.exec { commandLine = "git tag $newVersion".split(" ") @@ -72,7 +71,7 @@ class ReleaseHelperPlugin : Plugin { dependsOn("changelog", "getLatestTag") doLast { val latestTag: String by target.project.extra - val newVersion = latestTag.incrementVersion(VersionPart.MAJOR) + val newVersion = latestTag.incrementVersion(ReleaseType.MAJOR) target.updateVersionName(latestTag, newVersion) target.exec { commandLine = "git tag $newVersion".split(" ") @@ -82,18 +81,18 @@ class ReleaseHelperPlugin : Plugin { } } -private enum class VersionPart { +private enum class ReleaseType { MAJOR, MINOR, PATCH } -private fun String.incrementVersion(part: VersionPart) = split(".") +private fun String.incrementVersion(releaseType: ReleaseType) = split(".") .mapIndexed { index, numberString -> val number = numberString.toInt() - return@mapIndexed if (index == part.ordinal) { + return@mapIndexed if (index == releaseType.ordinal) { number + 1 - } else if (index > part.ordinal) { + } else if (index > releaseType.ordinal) { 0 } else { number