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

Changed files:\nCrossCompileGitForAndroid.sh
app/build.gradle.kts
app/src/main/java/com/kawomi/githugandroid/GitRuntime.kt
app/src/main/jniLibs/arm64-v8a/libgit.so
This commit is contained in:
Joe Tretter
2026-04-22 20:01:03 -05:00
parent d5f05dacb0
commit 97db212a04
4 changed files with 31 additions and 14 deletions

View File

@@ -11,8 +11,8 @@ android {
applicationId = "com.kawomi.githugandroid"
minSdk = 26
targetSdk = 34
versionCode = 10
versionName = "0.1.9"
versionCode = 11
versionName = "0.1.10"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

View File

@@ -2,6 +2,7 @@ package com.kawomi.githugandroid
import android.os.Build
import android.content.Context
import android.content.pm.ApplicationInfo
import java.io.File
class GitRepositoryRuntime(private val context: Context) {
@@ -9,7 +10,7 @@ class GitRepositoryRuntime(private val context: Context) {
private val extractedGitDir = File(context.filesDir, "native-git/bin")
fun startupBanner(): String {
return if (ensureNativeGitBinary() != null) {
return if (nativeGitBinary() != null) {
"Welcome to GitHug Android. Native Git prototype ready."
} else {
"Welcome to GitHug Android. Native Git binary not bundled for this ABI yet; using in-memory fallback."
@@ -17,7 +18,7 @@ class GitRepositoryRuntime(private val context: Context) {
}
fun prepareLevel(level: Level): RepoState {
val nativeGit = ensureNativeGitBinary()
val nativeGit = nativeGitBinary()
if (nativeGit == null) {
return level.setup()
}
@@ -52,7 +53,7 @@ class GitRepositoryRuntime(private val context: Context) {
}
fun execute(level: Level, currentRepo: RepoState, command: String): Pair<RepoState, List<String>> {
val nativeGit = ensureNativeGitBinary()
val nativeGit = nativeGitBinary()
if (nativeGit == null) {
return GitSandboxEngine.execute(currentRepo, command)
}
@@ -78,7 +79,8 @@ class GitRepositoryRuntime(private val context: Context) {
return buildList {
addAll(GitSandboxEngine.commandReferenceLines())
add("Native Git prototype:")
add(" extracted binary path: files/native-git/bin/git")
add(" preferred binary path: nativeLibraryDir/libgit.so")
add(" fallback binary path: files/native-git/bin/git")
add(" selected ABI: ${Build.SUPPORTED_ABIS.firstOrNull() ?: "unknown"}")
add(" helper commands: ls, pwd, cat, touch, mkdir, rm, echo")
}
@@ -132,7 +134,7 @@ class GitRepositoryRuntime(private val context: Context) {
private fun inspectSandbox(level: Level): RepoState {
val sandbox = sandboxDir(level)
val nativeGit = ensureNativeGitBinary()
val nativeGit = nativeGitBinary()
val filesOnDisk = sandbox.listFiles()
?.filter { it.isFile && it.name != ".git" }
.orEmpty()
@@ -180,7 +182,22 @@ class GitRepositoryRuntime(private val context: Context) {
)
}
private fun ensureNativeGitBinary(): File? {
private fun nativeGitBinary(): File? {
val packaged = packagedNativeGitBinary()
if (packaged != null) {
return packaged
}
return ensureExtractedAssetGitBinary()
}
private fun packagedNativeGitBinary(): File? {
val nativeLibraryDir = context.applicationInfo.nativeLibraryDir ?: return null
val candidate = File(nativeLibraryDir, "libgit.so")
return candidate.takeIf { it.exists() && it.canExecute() }
}
private fun ensureExtractedAssetGitBinary(): File? {
val extracted = File(extractedGitDir, "git")
if (extracted.exists() && extracted.canExecute()) {
return extracted

Binary file not shown.