Show build source and worktree state

This commit is contained in:
xXJsonDeruloXx committed 2026-09-24 09:40:50 -04:00
1 parent c11bca2dc2
commit 3345f1c32b
3 files changed
+28 -7

No files matched your search

+9 -2
View File
@@ -11,9 +11,9 @@ def gitValue = { List<String> arguments ->
workingDir rootProject.projectDir
ignoreExitValue = true
}
output.result.get().exitValue == 0 ? output.standardOutput.asText.get().trim() : ''
output.result.get().exitValue == 0 ? output.standardOutput.asText.get().trim() : null
} catch (Exception ignored) {
''
null
}
}
@@ -40,6 +40,13 @@ if (buildLabel == null || buildLabel.trim().isEmpty()) {
buildLabel = "${branch} at ${commit}"
}
}
def buildOrigin = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true' ? 'remote' : 'local'
def treeState = providers.environmentVariable('DROIDDECK_BUILD_TREE_STATE').getOrNull()
if (!(treeState in ['clean', 'dirty'])) {
def status = gitValue(['status', '--porcelain'])
treeState = status == null ? 'unknown' : (status.isEmpty() ? 'clean' : 'dirty')
}
buildLabel = "${buildOrigin} ${treeState} · ${buildLabel}"
def escapedBuildLabel = buildLabel.replace('\\', '\\\\').replace('"', '\\"')
android {
@@ -490,12 +490,15 @@ private fun BuildStatus(label: String, onCheckLatest: () -> Unit, modifier: Modi
val pal = LocalPalette.current
val interaction = remember { MutableInteractionSource() }
val hot = rememberHot(interaction)
val divider = label.lastIndexOf(" at ")
val branch = if (divider >= 0) label.substring(0, divider).substringAfterLast('/') else label
val displayLabel = if (divider >= 0) "$branch${label.substring(divider)}" else branch
val contextDivider = label.indexOf(" · ")
val context = if (contextDivider >= 0) label.substring(0, contextDivider) else ""
val identity = if (contextDivider >= 0) label.substring(contextDivider + 3) else label
val identityDivider = identity.lastIndexOf(" at ")
val branch = (if (identityDivider >= 0) identity.substring(0, identityDivider) else identity).substringAfterLast('/')
val commit = if (identityDivider >= 0) identity.substring(identityDivider + 4) else ""
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
horizontalArrangement = Arrangement.spacedBy(5.dp),
modifier = modifier
.fillMaxWidth()
.clip(RoundedCornerShape(6.dp))
@@ -510,7 +513,9 @@ private fun BuildStatus(label: String, onCheckLatest: () -> Unit, modifier: Modi
.heightIn(min = 40.dp)
.padding(horizontal = 4.dp),
) {
Text(displayLabel, modifier = Modifier.weight(1f), fontSize = 9.sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Medium, color = if (hot) colors.onSurfaceVariant else colors.onSurfaceVariant.copy(alpha = 0.82f), maxLines = 1, overflow = TextOverflow.Ellipsis)
if (context.isNotEmpty()) Text(context, fontSize = 8.sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Medium, color = colors.onSurfaceVariant.copy(alpha = 0.82f), maxLines = 1)
Text(branch, modifier = Modifier.weight(1f), fontSize = 9.sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Medium, color = if (hot) colors.onSurfaceVariant else colors.onSurfaceVariant.copy(alpha = 0.82f), maxLines = 1, overflow = TextOverflow.Ellipsis)
if (commit.isNotEmpty()) Text("@$commit", fontSize = 8.sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Medium, color = colors.onSurfaceVariant.copy(alpha = 0.82f), maxLines = 1)
Icon(Icons.Filled.Refresh, contentDescription = null, tint = if (hot) pal.signal else colors.onSurfaceVariant.copy(alpha = 0.82f), modifier = Modifier.size(12.dp))
}
}
+9
View File
@@ -2,6 +2,15 @@
set -euo pipefail
repo_root=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
if tree_status=$(git -C "${repo_root}" status --porcelain 2>/dev/null); then
if [[ -n "${tree_status}" ]]; then
export DROIDDECK_BUILD_TREE_STATE=dirty
else
export DROIDDECK_BUILD_TREE_STATE=clean
fi
else
export DROIDDECK_BUILD_TREE_STATE=unknown
fi
sdk_dir=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-"${HOME}/Library/Android/sdk"}}
java_dir=${JAVA_HOME:-"/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home"}
image_name=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v2}