Skip to content

Commit

Permalink
feat!: consider both annotated and lightweight tags by default
Browse files Browse the repository at this point in the history
To reproduce the previous behaviour, use:
```kotlin
gitSemVer {
    excludeLightweightTags()
}
```
  • Loading branch information
DanySK committed Jan 5, 2023
1 parent 5158fb3 commit 34a06dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ open class GitSemVerExtension @JvmOverloads constructor(
val buildMetadataSeparator: Property<String> = project.propertyWithDefault("+"),
val distanceCounterRadix: Property<Int> = project.propertyWithDefault(DEFAULT_RADIX),
val versionPrefix: Property<String> = project.propertyWithDefault(""),
val includeLightweightTags: Property<Boolean> = project.propertyWithDefault(false),
val includeLightweightTags: Property<Boolean> = project.propertyWithDefault(true),
) {

private fun computeMinVersion(logger: Logger): SemanticVersion {
Expand Down Expand Up @@ -157,8 +157,8 @@ open class GitSemVerExtension @JvmOverloads constructor(
/**
* If called, the system will also consider non-annotated tags.
*/
fun includeLightweightTags() {
includeLightweightTags.set(true)
fun excludeLightweightTags() {
includeLightweightTags.set(false)
}

companion object {
Expand Down
13 changes: 11 additions & 2 deletions src/test/kotlin/org/danilopianini/gradle/gitsemver/test/Tests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotContain
import org.gradle.internal.impldep.org.junit.rules.TemporaryFolder
import org.gradle.testkit.runner.GradleRunner
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -79,16 +80,24 @@ internal class Tests : StringSpec(
result shouldContain expectedVersion
}
"support for lightweight tags (#323)" {
val workingDirectory = configuredPlugin()
with(workingDirectory) {
initGit()
runCommand("git", "tag", "1.2.3")
}
workingDirectory.runGradle() shouldContain "1.2.3"
}
"exclusion of lightweight tags (#323)" {
val workingDirectory = configuredPlugin(
"""
includeLightweightTags()
excludeLightweightTags()
""".trimIndent()
)
with(workingDirectory) {
initGit()
runCommand("git", "tag", "1.2.3")
}
workingDirectory.runGradle() shouldContain "1.2.3"
workingDirectory.runGradle() shouldNotContain "1.2.3"
}
}
) {
Expand Down

0 comments on commit 34a06dd

Please sign in to comment.