- Remove the app fallback path when native Git is unavailable and show a startup blocker instead - Fix native level setup for staged file counting and cherry-pick parity - Improve manpage loading/search and bundle full Git documentation assets - Integrate Git cross-compilation into AndroidProjectTooling.sh and remove debug AAB support
30 lines
1.1 KiB
Kotlin
30 lines
1.1 KiB
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
data class GitHelpInvocation(
|
|
val topic: String,
|
|
val command: String,
|
|
)
|
|
|
|
fun parseGitHelpInvocation(command: String): GitHelpInvocation? {
|
|
val tokens = GitSandboxEngine.tokenizeCommand(command)
|
|
if (tokens.size >= 2 && tokens[0] == "man") {
|
|
val topic = when {
|
|
tokens[1] == "git" -> tokens.getOrNull(2) ?: "git"
|
|
tokens[1].startsWith("git-") -> tokens[1].removePrefix("git-")
|
|
tokens[1].startsWith("git") && tokens[1].length > 3 -> tokens[1].removePrefix("git")
|
|
else -> tokens[1]
|
|
}
|
|
.takeIf { it.matches(Regex("[A-Za-z0-9_-]+")) }
|
|
?: return null
|
|
return GitHelpInvocation(topic = topic, command = command)
|
|
}
|
|
if (tokens.size < 3 || tokens[0] != "git") return null
|
|
val topic = when {
|
|
tokens[1] == "help" -> tokens[2]
|
|
tokens[1] == "--help" -> tokens[2]
|
|
tokens.drop(2).any { it == "--help" } -> tokens[1]
|
|
else -> return null
|
|
}.takeIf { it.matches(Regex("[A-Za-z0-9_-]+")) } ?: return null
|
|
return GitHelpInvocation(topic = topic, command = command)
|
|
}
|