From 388c30f834ee5dcf7fdcd6fe5835c46132a1fc07 Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Tue, 23 Dec 2025 14:41:23 -0600 Subject: [PATCH] Update version_branch.yml --- .github/workflows/version_branch.yml | 30 ++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/version_branch.yml b/.github/workflows/version_branch.yml index 5147dab..2acb280 100644 --- a/.github/workflows/version_branch.yml +++ b/.github/workflows/version_branch.yml @@ -500,26 +500,48 @@ jobs: if [[ -f "update.xml" ]]; then echo "[INFO] update.xml present at repo root. Clearing contents because it is release generated only." + + # Ensure we can write chmod u+rw "update.xml" || true - # Robust truncation + # Hard clear using Python (bypasses shell redirection oddities) + python3 - <<'PY' + from pathlib import Path + p = Path('update.xml') + p.write_bytes(b'') + PY + + # Defense in depth : > "update.xml" || true truncate -s 0 "update.xml" || true SIZE_BYTES="$(wc -c < update.xml | tr -d ' ')" + if [[ "${SIZE_BYTES}" != "0" ]]; then - echo "[WARN] update.xml truncate returned ${SIZE_BYTES} bytes. Forcing recreate." + echo "[WARN] update.xml still ${SIZE_BYTES} bytes after clear. Forcing delete and recreate empty file." rm -f "update.xml" || true - : > "update.xml" + python3 - <<'PY' + from pathlib import Path + Path('update.xml').write_bytes(b'') + PY truncate -s 0 "update.xml" || true SIZE_BYTES="$(wc -c < update.xml | tr -d ' ')" fi - echo "[INFO] update.xml size after truncate: ${SIZE_BYTES} bytes" + echo "[INFO] update.xml size after clear: ${SIZE_BYTES} bytes" + if [[ "${SIZE_BYTES}" != "0" ]]; then + echo "[INFO] Debug: first 32 bytes (hex)" + od -An -tx1 -N 32 update.xml || true + echo "[INFO] Debug: file view (cat -A, first 5 lines)" + cat -A update.xml | head -n 5 || true echo "[FATAL] update.xml could not be cleared to 0 bytes." >&2 exit 2 fi + + echo "[INFO] Confirming working tree reflects empty update.xml" + git status --porcelain=v1 update.xml || true + git diff -- update.xml || true else echo "[INFO] update.xml not present. No action taken." fi