From 887ca6086ede4e0aea65b12088976f67f06844be Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 04:49:51 +0000 Subject: [PATCH] refactor(status): share git install label formatting --- src/commands/status-all.ts | 22 ++++++---------------- src/commands/status.command.ts | 17 ++--------------- src/infra/update-check.ts | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/commands/status-all.ts b/src/commands/status-all.ts index 25051a546bc..10c26c292e9 100644 --- a/src/commands/status-all.ts +++ b/src/commands/status-all.ts @@ -22,7 +22,11 @@ import { normalizeUpdateChannel, resolveEffectiveUpdateChannel, } from "../infra/update-channels.js"; -import { checkUpdateStatus, compareSemverStrings } from "../infra/update-check.js"; +import { + checkUpdateStatus, + compareSemverStrings, + formatGitInstallLabel, +} from "../infra/update-check.js"; import { runExec } from "../process/exec.js"; import { VERSION } from "../version.js"; import { resolveControlUiLinks } from "./onboard-helpers.js"; @@ -104,21 +108,7 @@ export async function statusAllCommand( gitTag: update.git?.tag ?? null, gitBranch: update.git?.branch ?? null, }); - const gitLabel = - update.installKind === "git" - ? (() => { - const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null; - const branch = - update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null; - const tag = update.git?.tag ?? null; - const parts = [ - branch ?? (tag ? "detached" : "git"), - tag ? `tag ${tag}` : null, - shortSha ? `@ ${shortSha}` : null, - ].filter(Boolean); - return parts.join(" · "); - })() - : null; + const gitLabel = formatGitInstallLabel(update); progress.tick(); progress.setLabel("Probing gateway…"); diff --git a/src/commands/status.command.ts b/src/commands/status.command.ts index 04d1c505c25..851bad625c3 100644 --- a/src/commands/status.command.ts +++ b/src/commands/status.command.ts @@ -12,6 +12,7 @@ import { normalizeUpdateChannel, resolveEffectiveUpdateChannel, } from "../infra/update-channels.js"; +import { formatGitInstallLabel } from "../infra/update-check.js"; import { resolveMemoryCacheSummary, resolveMemoryFtsState, @@ -357,21 +358,7 @@ export async function statusCommand( gitTag: update.git?.tag ?? null, gitBranch: update.git?.branch ?? null, }); - const gitLabel = - update.installKind === "git" - ? (() => { - const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null; - const branch = - update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null; - const tag = update.git?.tag ?? null; - const parts = [ - branch ?? (tag ? "detached" : "git"), - tag ? `tag ${tag}` : null, - shortSha ? `@ ${shortSha}` : null, - ].filter(Boolean); - return parts.join(" · "); - })() - : null; + const gitLabel = formatGitInstallLabel(update); const overviewRows = [ { Item: "Dashboard", Value: dashboard }, diff --git a/src/infra/update-check.ts b/src/infra/update-check.ts index d20621039d8..bdb11835c86 100644 --- a/src/infra/update-check.ts +++ b/src/infra/update-check.ts @@ -49,6 +49,21 @@ export type UpdateCheckResult = { registry?: RegistryStatus; }; +export function formatGitInstallLabel(update: UpdateCheckResult): string | null { + if (update.installKind !== "git") { + return null; + } + const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null; + const branch = update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null; + const tag = update.git?.tag ?? null; + const parts = [ + branch ?? (tag ? "detached" : "git"), + tag ? `tag ${tag}` : null, + shortSha ? `@ ${shortSha}` : null, + ].filter(Boolean); + return parts.join(" · "); +} + async function exists(p: string): Promise { try { await fs.access(p);