diff --git a/scripts/src/main/kotlin/scripts/release/calculateNewDevVersion.kt b/scripts/src/main/kotlin/scripts/release/calculateNewDevVersion.kt index 2734af3a57..ae02cef1ca 100644 --- a/scripts/src/main/kotlin/scripts/release/calculateNewDevVersion.kt +++ b/scripts/src/main/kotlin/scripts/release/calculateNewDevVersion.kt @@ -12,7 +12,7 @@ fun main(args: Array) { println("HI!") val projectDir = args[0] println("Working directory: $projectDir") - val (lastVersion, objectId) = getVersion(projectDir, onlyStable = true) + val (lastVersion, objectId) = getVersion(projectDir, ReleaseType.STABLE_NO_PATCH) println("Last version: $lastVersion, hash: ${objectId.name}") val branch = withRepo(projectDir) { it.branch } diff --git a/scripts/src/main/kotlin/scripts/release/calculateNewEapVersion.kt b/scripts/src/main/kotlin/scripts/release/calculateNewEapVersion.kt index f0aab76d29..5d91c26a4b 100644 --- a/scripts/src/main/kotlin/scripts/release/calculateNewEapVersion.kt +++ b/scripts/src/main/kotlin/scripts/release/calculateNewEapVersion.kt @@ -12,7 +12,7 @@ fun main(args: Array) { println("HI!") val projectDir = args[0] println("Working directory: $projectDir") - val (lastVersion, _) = getVersion(projectDir, onlyStable = false) + val (lastVersion, _) = getVersion(projectDir, ReleaseType.ANY) val nextVersion = if (lastVersion.suffixTokens.isEmpty()) { lastVersion.nextMinor().withSuffix("eap.1").value diff --git a/scripts/src/main/kotlin/scripts/release/calculateNewVersion.kt b/scripts/src/main/kotlin/scripts/release/calculateNewVersion.kt index c2f78fc1e5..67a9fd54ac 100644 --- a/scripts/src/main/kotlin/scripts/release/calculateNewVersion.kt +++ b/scripts/src/main/kotlin/scripts/release/calculateNewVersion.kt @@ -14,7 +14,7 @@ fun main(args: Array) { val releaseType = args[1] println("Working directory: $projectDir") println("Release type: $releaseType") - val (lastVersion, _) = getVersion(projectDir, onlyStable = true) + val (lastVersion, _) = getVersion(projectDir, ReleaseType.ONLY_STABLE) val nextVersion = when (releaseType) { "major" -> lastVersion.nextMajor() diff --git a/scripts/src/main/kotlin/scripts/release/util.kt b/scripts/src/main/kotlin/scripts/release/util.kt index a029ac0b17..dc0f278b01 100644 --- a/scripts/src/main/kotlin/scripts/release/util.kt +++ b/scripts/src/main/kotlin/scripts/release/util.kt @@ -58,7 +58,13 @@ internal fun checkBranch(rootDir: String, releaseType: String) { } } -internal fun getVersion(projectDir: String, onlyStable: Boolean): Pair { +enum class ReleaseType { + ANY, + ONLY_STABLE, + STABLE_NO_PATCH, // Version that ends on 0. Like 2.5.0 +} + +internal fun getVersion(projectDir: String, releaseType: ReleaseType): Pair { val repository = RepositoryBuilder().setGitDir(File("$projectDir/.git")).build() val git = Git(repository) println(git.log().call().first()) @@ -75,10 +81,10 @@ internal fun getVersion(projectDir: String, onlyStable: Boolean): Pair versions.last() + ReleaseType.ONLY_STABLE -> versions.last { it.first.isStable } + ReleaseType.STABLE_NO_PATCH -> versions.last { it.first.isStable && it.first.patch == 0 } } return version