Skip to content

Commit cbf15c8

Browse files
author
Joel Mongård
committed
fix: The printSemVersion task does not use the new metaSeparator settings (#80)
1 parent 431f5dc commit cbf15c8

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/main/kotlin/git/semver/plugin/gradle/GitSemverPlugin.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,36 @@ import org.gradle.api.Project
88
/**
99
* The plugin entry point
1010
*/
11-
class GitSemverPlugin: Plugin<Project> {
11+
class GitSemverPlugin : Plugin<Project> {
1212
companion object {
1313
const val VERSIONING_GROUP = "Versioning"
1414
}
1515

1616
override fun apply(project: Project) {
1717
val extension = project.extensions.create("semver", GitSemverPluginExtension::class.java, project)
1818

19-
project.tasks.register("printVersion", PrintTask::class.java, extension::versionValue, "Prints the current project version", "")
20-
project.tasks.register("printSemVersion", PrintTask::class.java, extension::semVersion, "Prints the current project semantic version", "")
21-
project.tasks.register("printInfoVersion", PrintTask::class.java, extension::infoVersion, "Prints the current project info version", "")
19+
project.tasks.register(
20+
"printVersion", PrintTask::class.java, {
21+
extension.versionValue.toString(extension.useTwoDigitVersion)
22+
}, "Prints the current project version", ""
23+
)
24+
project.tasks.register(
25+
"printSemVersion", PrintTask::class.java, {
26+
extension.semVersion.toInfoVersionString(
27+
shaLength = 7,
28+
useTwoDigitVersion = extension.useTwoDigitVersion,
29+
metaSeparator = extension.metaSeparator
30+
)
31+
}, "Prints the current project semantic version", ""
32+
)
33+
project.tasks.register(
34+
"printInfoVersion", PrintTask::class.java, {
35+
extension.semVersion.toInfoVersionString(
36+
metaSeparator = extension.metaSeparator,
37+
useTwoDigitVersion = extension.useTwoDigitVersion
38+
)
39+
}, "Prints the current project info version", ""
40+
)
2241

2342
if (project == project.rootProject) {
2443
project.tasks.register("printChangeLog", PrintTask::class.java, {

src/test/kotlin/git/semver/plugin/gradle/GitSemverPluginTest.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GitSemverPluginTest {
2828
project.plugins.apply("com.github.jmongard.git-semver-plugin")
2929
val c = project.extensions.findByName("semver") as GitSemverPluginExtension
3030
c.defaultPreRelease = "XYZ"
31+
c.metaSeparator = '¤'
3132

3233
val task = project.tasks.findByName(name) as PrintTask
3334

@@ -36,9 +37,12 @@ class GitSemverPluginTest {
3637
task.setFile(outFile.toString())
3738
task.print()
3839

39-
if (name.endsWith("Version"))
40-
assertThat(outFile).exists().isNotEmptyFile().content().doesNotContain("SNAPSHOT").contains(c.version)
41-
else
40+
if (name.endsWith("Version")) {
41+
assertThat(outFile).exists().isNotEmptyFile().content()
42+
.doesNotContain("SNAPSHOT")
43+
.contains(c.version)
44+
.doesNotContain("+")
45+
} else
4246
assertThat(outFile).exists().isNotEmptyFile().content().startsWith("#")
4347
}
4448

0 commit comments

Comments
 (0)