From 3345f1c32b7c1b0ab80345315b9a04cedf5288e3 Mon Sep 17 00:00:00 2001 From: xXJsonDeruloXx Date: Thu, 24 Sep 2026 09:40:50 -0400 Subject: [PATCH] Show build source and worktree state --- app/build.gradle | 11 +++++++++-- .../com/droiddeck/launcher/ui/FrontEndScreen.kt | 15 ++++++++++----- tools/build_local.sh | 9 +++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bf8efebbe9..7fa1adc1bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,9 +11,9 @@ def gitValue = { List 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 { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 38a65ac75c..5a9c592d81 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -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)) } } diff --git a/tools/build_local.sh b/tools/build_local.sh index 450fef9cc3..cd831a8dfe 100755 --- a/tools/build_local.sh +++ b/tools/build_local.sh @@ -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}