From: Alexander Goussas Date: Fri, 24 Oct 2025 15:30:17 +0000 (-0500) Subject: feat: add git command executors X-Git-Url: http://git.frustrated-labs.net/?a=commitdiff_plain;h=63215434e6886845be03429dc6bd2ce61f83846f;p=gradle-changelog-plugin.git feat: add git command executors --- diff --git a/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/AbstractGitCommand.kt b/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/AbstractGitCommand.kt new file mode 100644 index 0000000..13ceb33 --- /dev/null +++ b/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/AbstractGitCommand.kt @@ -0,0 +1,15 @@ +package io.github.aloussase.changelog.git + +abstract class AbstractGitCommand : GitCommand { + + override fun execute(): String { + val runtime = Runtime.getRuntime() + val ary = arrayOf("/bin/sh", "-c", commandLine) + val process = runtime.exec(ary) + process.waitFor() + return process.inputReader().use { br -> + br.readText().trim() + } + } + +} diff --git a/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GetCurrentReleaseCommand.kt b/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GetCurrentReleaseCommand.kt new file mode 100644 index 0000000..3bea08d --- /dev/null +++ b/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GetCurrentReleaseCommand.kt @@ -0,0 +1,6 @@ +package io.github.aloussase.changelog.git + +class GetCurrentReleaseCommand : AbstractGitCommand() { + override val commandLine: String + get() = "git tag | tail -n1" +} diff --git a/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GitCommand.kt b/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GitCommand.kt new file mode 100644 index 0000000..eb18e17 --- /dev/null +++ b/changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GitCommand.kt @@ -0,0 +1,9 @@ +package io.github.aloussase.changelog.git + +interface GitCommand { + + val commandLine: String + + fun execute(): String + +}