import io.github.aloussase.changelog.config.Config
import io.github.aloussase.changelog.formatter.ChangelogFormatterFactory
-import io.github.aloussase.changelog.git.GetCurrentBranchCommits
+import io.github.aloussase.changelog.git.GetCurrentBranchCommand
import io.github.aloussase.changelog.parser.ChangelogParserFactory
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
val changelog = parser.parse(document).getOrThrow()
// TODO: Add commits from current branch here.
- println(GetCurrentBranchCommits().execute())
+ println(GetCurrentBranchCommand().execute())
val formatter = ChangelogFormatterFactory.create(config.documentFormat)
changelogFile.writeText(formatter.format(changelog))
--- /dev/null
+package io.github.aloussase.changelog.git
+
+class GetCurrentBranchCommand : AbstractGitCommand<String>() {
+ override fun transform(rawOutput: String): String = rawOutput
+
+ override val commandLine: String
+ get() = "git branch --show-current"
+}
+++ /dev/null
-package io.github.aloussase.changelog.git
-
-class GetCurrentBranchCommits : AbstractGitCommand<List<Pair<String, String>>>() {
- override val commandLine: String
- get() = "git log main..HEAD --no-merges --oneline --pretty=format:\"%an|%s\""
-
- override fun transform(rawOutput: String): List<Pair<String, String>> =
- rawOutput
- .split("\n")
- .map { it.split("|") }
- .map { Pair(it[0], it[1]) }
-}
--- /dev/null
+package io.github.aloussase.changelog.git
+
+class GetCurrentBranchCommitsCommand : AbstractGitCommand<List<Pair<String, String>>>() {
+ override val commandLine: String
+ get() = "git log main..HEAD --no-merges --oneline --pretty=format:\"%an|%s\""
+
+ override fun transform(rawOutput: String): List<Pair<String, String>> =
+ rawOutput
+ .split("\n")
+ .map { it.split("|") }
+ .map { Pair(it[0], it[1]) }
+}