Auto-commit after successful build: update app gameplay/UI, improve build setup

Changed files:\napp/build.gradle.kts
app/src/main/java/solutions/tretter/githugandroid/GitEditorCommands.kt
app/src/main/java/solutions/tretter/githugandroid/GitHugApp.kt
app/src/main/java/solutions/tretter/githugandroid/GitMessageEditorDialog.kt
app/src/main/java/solutions/tretter/githugandroid/GitRuntime.kt
app/src/test/java/solutions/tretter/githugandroid/GitEditorCommandsTest.kt
This commit is contained in:
Joe Tretter
2026-05-02 23:03:00 -05:00
parent 01d10f31c2
commit 4963123b3b
6 changed files with 313 additions and 2 deletions

View File

@@ -61,6 +61,7 @@ fun GitHugApp() {
var historyDraft by remember { mutableStateOf("") }
var hasRestoredProgress by remember { mutableStateOf(false) }
var editorState by remember { mutableStateOf<TextEditorState?>(null) }
var gitMessageEditorState by remember { mutableStateOf<GitMessageEditorState?>(null) }
var manPageState by remember { mutableStateOf<ManPageState?>(null) }
val currentLevel = levels[currentLevelIndex]
@@ -173,6 +174,7 @@ fun GitHugApp() {
historyIndex = -1
historyDraft = ""
editorState = null
gitMessageEditorState = null
manPageState = null
applyRecommendedPaneWeights(persist = false)
}
@@ -190,6 +192,7 @@ fun GitHugApp() {
historyIndex = -1
historyDraft = ""
editorState = null
gitMessageEditorState = null
manPageState = null
paneLayout = paneLayout.copy(
weights = paneLayout.weights + recommendedPaneWeights(
@@ -341,6 +344,19 @@ fun GitHugApp() {
applyRecommendedPaneWeights(persist = false)
}
fun openGitMessageEditor(invocation: GitEditorInvocation) {
output = buildList {
addAll(output)
add("$ ${invocation.command}")
add("Opened Git message editor")
}
gitMessageEditorState = GitMessageEditorState(
invocation = invocation,
content = invocation.initialContent,
)
applyRecommendedPaneWeights(persist = false)
}
fun saveEditor() {
val state = editorState ?: return
val targetPath = state.saveAsPath.trim()
@@ -350,6 +366,18 @@ fun GitHugApp() {
applyCommandResult(state.originalCommand, newRepo, lines, echoCommand = false)
}
fun saveGitMessageEditor() {
val state = gitMessageEditorState ?: return
val (newRepo, lines) = runtime.executeGitEditorCommand(
level = currentLevel,
currentRepo = repo,
invocation = state.invocation,
message = state.content,
)
gitMessageEditorState = null
applyCommandResult(state.invocation.command, newRepo, lines, echoCommand = false)
}
fun runCommand() {
val submittedText = commandInput.text
val raw = submittedText.trim()
@@ -376,6 +404,12 @@ fun GitHugApp() {
return
}
val gitEditorInvocation = parseGitEditorInvocation(raw)
if (gitEditorInvocation != null) {
openGitMessageEditor(gitEditorInvocation)
return
}
val (newRepo, lines) = runtime.execute(currentLevel, repo, raw)
applyCommandResult(raw, newRepo, lines, echoCommand = true)
}
@@ -485,6 +519,18 @@ fun GitHugApp() {
)
}
gitMessageEditorState?.let { state ->
GitMessageEditorDialog(
state = state,
onContentChange = { gitMessageEditorState = state.copy(content = it) },
onClose = {
output = output + "Git editor closed without saving"
gitMessageEditorState = null
},
onSave = { saveGitMessageEditor() },
)
}
manPageState?.let { state ->
ManPageDialog(
state = state,