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

Changed files:\napp/build.gradle.kts
app/src/main/java/com/kawomi/githugandroid/GameModels.kt
app/src/main/java/com/kawomi/githugandroid/GitRuntime.kt
This commit is contained in:
Joe Tretter
2026-04-23 23:01:54 -05:00
parent be60423f01
commit 54e7e91339
3 changed files with 57 additions and 37 deletions

View File

@@ -25,6 +25,7 @@ data class RepoState(
val commits: List<CommitNode> = emptyList(),
val headBranch: String = "master",
val branches: Map<String, Int> = emptyMap(),
val currentDir: String = ".",
)
data class Level(
@@ -75,6 +76,7 @@ val RepoStateSaver = listSaver<RepoState, Any>(
state.files.flatMap { listOf(it.name, it.content, it.staged.toString(), it.tracked.toString()) },
state.commits.flatMap { listOf(it.id, it.message) },
state.branches.flatMap { listOf(it.key, it.value.toString()) },
state.currentDir,
)
},
restore = { saved ->
@@ -97,7 +99,8 @@ val RepoStateSaver = listSaver<RepoState, Any>(
commits = commitParts.chunked(2).map {
CommitNode(it[0] as String, it[1] as String)
},
branches = branchParts.chunked(2).associate { (it[0] as String) to (it[1] as String).toInt() }
branches = branchParts.chunked(2).associate { (it[0] as String) to (it[1] as String).toInt() },
currentDir = saved[5] as String,
)
}
)
@@ -105,19 +108,17 @@ val RepoStateSaver = listSaver<RepoState, Any>(
object GitSandboxEngine {
fun commandReferenceLines(): List<String> = listOf(
"Available sandbox commands:",
" git init",
" git status",
" git add <file>",
" git add .",
" git commit -m \"message\"",
" git commit -am \"message\"",
" git log",
" git branch <name>",
" git checkout <name>",
" git ",
" ls",
" touch <file>",
" help",
" git help",
" pwd ",
" cat <file>",
" touch <file>",
" mkdir <directory>",
" cd <directory>",
" rm <file>",
" echo <message>",
)
fun execute(repo: RepoState, command: String): Pair<RepoState, List<String>> {