Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

chore(ok): assessed gate quick-wins - cadence, cancel backstop, i18n restore, hook race (#4059)

Nick Gomez3e963c32bbf4
diff --git a/scripts/check-i18n-drift.sh b/scripts/check-i18n-drift.sh
index a5e0b2e87..8dfd03961 100755
--- a/scripts/check-i18n-drift.sh
+++ b/scripts/check-i18n-drift.sh
@@ -17,15 +17,56 @@
# script stays clean after a no-drift run.
set -euo pipefail
+unset GIT_DIR GIT_WORK_TREE GIT_COMMON_DIR GIT_INDEX_FILE \
+ GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_NAMESPACE GIT_PREFIX
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
LOCALES_DIR="packages/app/src/locales"
+SNAPSHOT_ROOT="$(mktemp -d)"
+SNAPSHOT_READY=0
+CATALOGS_SETTLED=0
+EXTRACT_PID=''
+STAGED_RESTORE="$REPO_ROOT/$LOCALES_DIR.restore.$$"
+restore_catalogs() {
+ set +e
+ if [ -n "$EXTRACT_PID" ]; then
+ kill -- "-$EXTRACT_PID" 2>/dev/null
+ wait "$EXTRACT_PID" 2>/dev/null
+ fi
+ if [ "$SNAPSHOT_READY" -eq 1 ] && [ "$CATALOGS_SETTLED" -eq 0 ]; then
+ rm -rf "${STAGED_RESTORE:?}"
+ if ! { cp -Rp "$SNAPSHOT_ROOT/locales" "${STAGED_RESTORE:?}" &&
+ rm -rf "${REPO_ROOT:?}/$LOCALES_DIR" &&
+ mv "${STAGED_RESTORE:?}" "${REPO_ROOT:?}/$LOCALES_DIR"; }; then
+ echo "FATAL: could not restore $LOCALES_DIR. The pre-run catalogs are kept at" >&2
+ echo " $SNAPSHOT_ROOT/locales" >&2
+ echo "Copy them back before running anything else." >&2
+ rm -rf "${STAGED_RESTORE:?}"
+ return
+ fi
+ fi
+ rm -rf "$SNAPSHOT_ROOT"
+}
+trap restore_catalogs EXIT
+cp -Rp "$REPO_ROOT/$LOCALES_DIR" "$SNAPSHOT_ROOT/locales"
+SNAPSHOT_READY=1
+
+cd "$REPO_ROOT"
+UNTRACKED_BEFORE="$(git ls-files --others --exclude-standard -- "$LOCALES_DIR")"
+
cd "$REPO_ROOT/packages/app"
-pnpm run --silent i18n >/dev/null
+set -m
+pnpm run --silent i18n >/dev/null &
+EXTRACT_PID=$!
+set +m
+wait "$EXTRACT_PID"
+EXTRACT_PID=''
cd "$REPO_ROOT"
-if ! git diff --quiet -- "$LOCALES_DIR"; then
+UNTRACKED_AFTER="$(git ls-files --others --exclude-standard -- "$LOCALES_DIR")"
+if ! git diff --quiet -- "$LOCALES_DIR" || [ "$UNTRACKED_BEFORE" != "$UNTRACKED_AFTER" ]; then
echo "ERROR: i18n catalog drift detected." >&2
echo "" >&2
echo " <Trans> or t\`...\` macros under packages/app/src have changed without" >&2
@@ -38,5 +79,11 @@ if ! git diff --quiet -- "$LOCALES_DIR"; then
echo "" >&2
echo " Drift summary:" >&2
git --no-pager diff --stat -- "$LOCALES_DIR" >&2
+ if [ "$UNTRACKED_BEFORE" != "$UNTRACKED_AFTER" ]; then
+ echo " Catalog files the extractor created:" >&2
+ comm -13 <(printf '%s\n' "$UNTRACKED_BEFORE" | sed '/^$/d' | sort -u) \
+ <(printf '%s\n' "$UNTRACKED_AFTER" | sed '/^$/d' | sort -u) >&2
+ fi
exit 1
fi
+CATALOGS_SETTLED=1