Open app editor for interactive rebase todo

This commit is contained in:
Joe Tretter
2026-05-18 19:01:12 -05:00
parent d4e2c8714c
commit ce58f46b48
6 changed files with 148 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package solutions.tretter.githugandroid
enum class GitEditorCommandKind {
COMMIT_MESSAGE,
REBASE_TODO,
TAG_MESSAGE,
}
@@ -18,6 +19,7 @@ fun parseGitEditorInvocation(command: String): GitEditorInvocation? {
return when (tokens[1]) {
"commit" -> parseGitCommitEditor(command, tokens.drop(2))
"rebase" -> parseGitRebaseEditor(command, tokens.drop(2))
"tag" -> parseGitTagEditor(command, tokens.drop(2))
else -> null
}
@@ -35,6 +37,19 @@ private fun parseGitCommitEditor(command: String, arguments: List<String>): GitE
)
}
private fun parseGitRebaseEditor(command: String, arguments: List<String>): GitEditorInvocation? {
val interactive = arguments.any { it == "-i" || it == "--interactive" }
if (!interactive) return null
val target = arguments.lastOrNull { it != "-i" && it != "--interactive" && !it.startsWith("-") }
if (target == null) return null
return GitEditorInvocation(
command = command,
kind = GitEditorCommandKind.REBASE_TODO,
title = "Edit Rebase Todo",
)
}
private fun parseGitTagEditor(command: String, arguments: List<String>): GitEditorInvocation? {
val needsMessage = arguments.any { it == "-a" || it == "-s" || it == "--annotate" || it == "--sign" }
if (!needsMessage) return null