Added reset of lower version numbers on increment.
This commit is contained in:
parent
6d20d5f9d0
commit
b67c5a33de
3 changed files with 24 additions and 6 deletions
|
@ -32,7 +32,6 @@
|
|||
package net.thauvin.erik.gradle.semver
|
||||
|
||||
open class SemverConfig {
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_KEY_PREFIX = "version."
|
||||
const val DEFAULT_PROPERTIES = "${DEFAULT_KEY_PREFIX}properties"
|
||||
|
|
|
@ -57,8 +57,15 @@ class Version {
|
|||
(if (buildMeta.isNotEmpty()) "$buildMetaPrefix$buildMeta" else "")
|
||||
|
||||
fun increment(isMajor: Boolean = false, isMinor: Boolean = false, isPatch: Boolean = false) {
|
||||
if (isMajor) major = (major.toInt() + 1).toString()
|
||||
if (isMinor) minor = (minor.toInt() + 1).toString()
|
||||
if (isMajor) {
|
||||
major = (major.toInt() + 1).toString()
|
||||
minor = "0"
|
||||
patch = "0"
|
||||
}
|
||||
if (isMinor) {
|
||||
minor = (minor.toInt() + 1).toString()
|
||||
patch = "0"
|
||||
}
|
||||
if (isPatch) patch = (patch.toInt() + 1).toString()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,10 +61,22 @@ object SemverVersionSpec : Spek({
|
|||
assertEquals("2.1.1", version.semver)
|
||||
}
|
||||
}
|
||||
on("increment patch") {
|
||||
version.increment(isMinor = true)
|
||||
it("should return 2.1.0") {
|
||||
assertEquals("2.1.0", version.semver)
|
||||
}
|
||||
}
|
||||
on("increment patch") {
|
||||
version.increment(isMajor = true)
|
||||
it("should return 3.0.0") {
|
||||
assertEquals("3.0.0", version.semver)
|
||||
}
|
||||
}
|
||||
on("increment all") {
|
||||
version.increment(true, true, true)
|
||||
it("should rerturn 3.2.2") {
|
||||
assertEquals("3.2.2", version.semver)
|
||||
it("should return 3.1.1") {
|
||||
assertEquals("3.1.1", version.semver)
|
||||
}
|
||||
}
|
||||
on("reset version") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue