]> git.frustrated-labs.net Git - gradle-changelog-plugin.git/commitdiff
feat: add git command executors
authorAlexander Goussas <[email protected]>
Fri, 24 Oct 2025 15:30:17 +0000 (10:30 -0500)
committerAlexander Goussas <[email protected]>
Fri, 24 Oct 2025 16:47:10 +0000 (11:47 -0500)
changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/AbstractGitCommand.kt [new file with mode: 0644]
changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GetCurrentReleaseCommand.kt [new file with mode: 0644]
changelog-plugin/src/main/kotlin/io/github/aloussase/changelog/git/GitCommand.kt [new file with mode: 0644]

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 (file)
index 0000000..13ceb33
--- /dev/null
@@ -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 (file)
index 0000000..3bea08d
--- /dev/null
@@ -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 (file)
index 0000000..eb18e17
--- /dev/null
@@ -0,0 +1,9 @@
+package io.github.aloussase.changelog.git
+
+interface GitCommand {
+
+    val commandLine: String
+
+    fun execute(): String
+
+}