fix(ui): display short commit SHA next to Tachyon version in UI and constants
This commit is contained in:
@@ -255,8 +255,13 @@ build_backend_root() {
|
||||
install -m 0755 "$ROOT_DIR/tachyon/files/usr/bin/tachyon" "$output_root/usr/bin/tachyon"
|
||||
cp -a "$ROOT_DIR/tachyon/files/usr/lib/." "$output_root/usr/lib/tachyon/"
|
||||
|
||||
local commit_sha="${GIT_COMMIT_SHA:-}"
|
||||
if [[ -z "$commit_sha" || "$commit_sha" == "unknown" ]]; then
|
||||
commit_sha="$(git -C "$ROOT_DIR" rev-parse --short HEAD 2>/dev/null || echo "unknown")"
|
||||
fi
|
||||
|
||||
sed -i -e "s/__COMPILED_VERSION_VARIABLE__/${RELEASE_VERSION}/g" \
|
||||
-e "s/__COMPILED_COMMIT_SHA__/${GIT_COMMIT_SHA}/g" \
|
||||
-e "s/__COMPILED_COMMIT_SHA__/${commit_sha}/g" \
|
||||
"$output_root/usr/lib/tachyon/core/constants.uc"
|
||||
|
||||
normalize_package_root_modes "$output_root"
|
||||
|
||||
@@ -1061,13 +1061,23 @@ function renderComponentCard(card: ComponentCard) {
|
||||
const anyActionLoading = isAnyActionLoading();
|
||||
const systemInfoLoading = isSystemInfoLoading();
|
||||
|
||||
const checkResult = getVisibleCheckResult(card.component);
|
||||
let versionText = card.version;
|
||||
const sha =
|
||||
checkResult?.current_sha ||
|
||||
store.get().diagnosticsSystemInfo?.tachyon_commit_sha;
|
||||
if (card.component === 'tachyon' && sha && sha !== 'unknown') {
|
||||
const shortSha = sha.substring(0, 7);
|
||||
versionText = `${card.version} (${shortSha})`;
|
||||
}
|
||||
|
||||
// 1. Header (displays Title, Current Version, no badges)
|
||||
const headerChildren: Node[] = [
|
||||
E('b', { class: 'tachyon_updates-page__component__title' }, card.title),
|
||||
E(
|
||||
'span',
|
||||
{ class: 'tachyon_updates-page__component__header-version' },
|
||||
card.version,
|
||||
versionText,
|
||||
),
|
||||
];
|
||||
if (card.repoUrl) {
|
||||
@@ -1093,7 +1103,6 @@ function renderComponentCard(card: ComponentCard) {
|
||||
|
||||
// 2. Details (renders status messages for check results)
|
||||
const detailsChildren: Node[] = [];
|
||||
const checkResult = getVisibleCheckResult(card.component);
|
||||
|
||||
if (checkResult && checkResult.status) {
|
||||
let labelText = '';
|
||||
|
||||
@@ -14798,12 +14798,19 @@ function renderComponentCard(card) {
|
||||
const updatesActions = store.get().updatesActions;
|
||||
const anyActionLoading = isAnyActionLoading();
|
||||
const systemInfoLoading = isSystemInfoLoading();
|
||||
const checkResult = getVisibleCheckResult(card.component);
|
||||
let versionText = card.version;
|
||||
const sha = checkResult?.current_sha || store.get().diagnosticsSystemInfo?.tachyon_commit_sha;
|
||||
if (card.component === "tachyon" && sha && sha !== "unknown") {
|
||||
const shortSha = sha.substring(0, 7);
|
||||
versionText = `${card.version} (${shortSha})`;
|
||||
}
|
||||
const headerChildren = [
|
||||
E("b", { class: "tachyon_updates-page__component__title" }, card.title),
|
||||
E(
|
||||
"span",
|
||||
{ class: "tachyon_updates-page__component__header-version" },
|
||||
card.version
|
||||
versionText
|
||||
)
|
||||
];
|
||||
if (card.repoUrl) {
|
||||
@@ -14827,7 +14834,6 @@ function renderComponentCard(card) {
|
||||
headerChildren
|
||||
);
|
||||
const detailsChildren = [];
|
||||
const checkResult = getVisibleCheckResult(card.component);
|
||||
if (checkResult && checkResult.status) {
|
||||
let labelText = "";
|
||||
const latestValueNodes = [];
|
||||
|
||||
@@ -62,11 +62,31 @@ function detect_installed_version() {
|
||||
return "";
|
||||
}
|
||||
|
||||
function detect_installed_commit_sha() {
|
||||
let sha = env("TACHYON_COMMIT_SHA", "__COMPILED_COMMIT_SHA__");
|
||||
if (sha != "" && !match(sha, /COMPILED/) && sha != "unknown")
|
||||
return sha;
|
||||
|
||||
let file_sha = trim(as_string(fs.readfile("/etc/tachyon_commit")));
|
||||
if (file_sha != "" && file_sha != "unknown")
|
||||
return file_sha;
|
||||
|
||||
let proc = fs.popen("git rev-parse --short HEAD 2>/dev/null");
|
||||
if (proc != null) {
|
||||
let git_sha = trim(as_string(proc.read("all")));
|
||||
proc.close();
|
||||
if (git_sha != "" && match(git_sha, /^[0-9a-fA-F]{7,40}$/) != null)
|
||||
return git_sha;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function constants_map() {
|
||||
let c = {};
|
||||
|
||||
c.TACHYON_VERSION = detect_installed_version();
|
||||
c.TACHYON_COMMIT_SHA = env("TACHYON_COMMIT_SHA", "__COMPILED_COMMIT_SHA__");
|
||||
c.TACHYON_COMMIT_SHA = detect_installed_commit_sha();
|
||||
c.TACHYON_CONFIG_NAME = env("TACHYON_CONFIG_NAME", "tachyon");
|
||||
c.TACHYON_CONFIG = env("TACHYON_CONFIG", "/etc/config/" + c.TACHYON_CONFIG_NAME);
|
||||
c.TACHYON_BIN = env("TACHYON_BIN", "/usr/bin/tachyon");
|
||||
|
||||
Reference in New Issue
Block a user