Rename VersionPart to ReleaseType
This commit is contained in:
parent
c04e2ded8e
commit
80e323b326
1 changed files with 7 additions and 8 deletions
|
@ -2,7 +2,6 @@ package com.wbrawner.releasehelper
|
||||||
|
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.provider.Provider
|
|
||||||
import org.gradle.api.tasks.Exec
|
import org.gradle.api.tasks.Exec
|
||||||
import org.gradle.kotlin.dsl.extra
|
import org.gradle.kotlin.dsl.extra
|
||||||
import org.gradle.kotlin.dsl.provideDelegate
|
import org.gradle.kotlin.dsl.provideDelegate
|
||||||
|
@ -48,7 +47,7 @@ class ReleaseHelperPlugin : Plugin<Project> {
|
||||||
dependsOn("changelog", "getLatestTag")
|
dependsOn("changelog", "getLatestTag")
|
||||||
doLast {
|
doLast {
|
||||||
val latestTag: String by target.project.extra
|
val latestTag: String by target.project.extra
|
||||||
val newVersion = latestTag.incrementVersion(VersionPart.MAJOR)
|
val newVersion = latestTag.incrementVersion(ReleaseType.MAJOR)
|
||||||
target.updateVersionName(latestTag, newVersion)
|
target.updateVersionName(latestTag, newVersion)
|
||||||
target.exec {
|
target.exec {
|
||||||
commandLine = "git tag $newVersion".split(" ")
|
commandLine = "git tag $newVersion".split(" ")
|
||||||
|
@ -60,7 +59,7 @@ class ReleaseHelperPlugin : Plugin<Project> {
|
||||||
dependsOn("changelog", "getLatestTag")
|
dependsOn("changelog", "getLatestTag")
|
||||||
doLast {
|
doLast {
|
||||||
val latestTag: String by target.project.extra
|
val latestTag: String by target.project.extra
|
||||||
val newVersion = latestTag.incrementVersion(VersionPart.MAJOR)
|
val newVersion = latestTag.incrementVersion(ReleaseType.MAJOR)
|
||||||
target.updateVersionName(latestTag, newVersion)
|
target.updateVersionName(latestTag, newVersion)
|
||||||
target.exec {
|
target.exec {
|
||||||
commandLine = "git tag $newVersion".split(" ")
|
commandLine = "git tag $newVersion".split(" ")
|
||||||
|
@ -72,7 +71,7 @@ class ReleaseHelperPlugin : Plugin<Project> {
|
||||||
dependsOn("changelog", "getLatestTag")
|
dependsOn("changelog", "getLatestTag")
|
||||||
doLast {
|
doLast {
|
||||||
val latestTag: String by target.project.extra
|
val latestTag: String by target.project.extra
|
||||||
val newVersion = latestTag.incrementVersion(VersionPart.MAJOR)
|
val newVersion = latestTag.incrementVersion(ReleaseType.MAJOR)
|
||||||
target.updateVersionName(latestTag, newVersion)
|
target.updateVersionName(latestTag, newVersion)
|
||||||
target.exec {
|
target.exec {
|
||||||
commandLine = "git tag $newVersion".split(" ")
|
commandLine = "git tag $newVersion".split(" ")
|
||||||
|
@ -82,18 +81,18 @@ class ReleaseHelperPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum class VersionPart {
|
private enum class ReleaseType {
|
||||||
MAJOR,
|
MAJOR,
|
||||||
MINOR,
|
MINOR,
|
||||||
PATCH
|
PATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.incrementVersion(part: VersionPart) = split(".")
|
private fun String.incrementVersion(releaseType: ReleaseType) = split(".")
|
||||||
.mapIndexed { index, numberString ->
|
.mapIndexed { index, numberString ->
|
||||||
val number = numberString.toInt()
|
val number = numberString.toInt()
|
||||||
return@mapIndexed if (index == part.ordinal) {
|
return@mapIndexed if (index == releaseType.ordinal) {
|
||||||
number + 1
|
number + 1
|
||||||
} else if (index > part.ordinal) {
|
} else if (index > releaseType.ordinal) {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
number
|
number
|
||||||
|
|
Loading…
Reference in a new issue