52 lines
2.9 KiB
Bash
Executable File
52 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# /workspace/hyperdope-ci-build/integrate-upstream-and-ui.sh
|
|
# Integrates upstream `malonehunter/hyperdope-gematria` (`origin/master`) with:
|
|
# Layer 1 (`feat/ingglish-aq-corpus`): Verified Ingglish AQ corpus (`db.txt`) + `tools/normalize_caps.py` guard + `docs/ONBOARDING-INGGLISH-AQ.md`
|
|
# Layer 2 (`feat/ingglish-priority-toggle`): `patches/0001-feat-calc-ingglish-priority-toggle.patch` (`ING ↑` query match priority toggle)
|
|
# Layer 3 (`main` / `feat/group3-homepage-ui-and-branding`): `patches/0002-feat-ui-group3-homepage-parity-and-haiperdohpjematreeah-branding.patch`
|
|
# and regenerates clean upstream PR patches whenever UI or corpus changes are made in `haiperdohp-jemaytreeah`.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
CALC_REPO="${1:-/workspace/haiperdohp-jemaytreeah}"
|
|
MODE="${2:---export-patches}"
|
|
|
|
if [[ ! -d "${CALC_REPO}/.git" ]]; then
|
|
echo "[ERROR] Target calculator repository not found at ${CALC_REPO}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "${SCRIPT_DIR}/patches"
|
|
PATCH_1="${SCRIPT_DIR}/patches/0001-feat-calc-ingglish-priority-toggle.patch"
|
|
PATCH_2="${SCRIPT_DIR}/patches/0002-feat-ui-group3-homepage-parity-and-haiperdohpjematreeah-branding.patch"
|
|
|
|
if [[ "${MODE}" == "--export-patches" ]]; then
|
|
echo "[1/2] Exporting clean Layer 2 (ING ↑ Priority Toggle) & Layer 3 (Group 3 Homepage UI & haiperdohpjematreeah Branding) patches from ${CALC_REPO}..."
|
|
git -C "${CALC_REPO}" diff feat/ingglish-aq-corpus..feat/ingglish-priority-toggle -- calc/calc.js calc/database.js > "${PATCH_1}"
|
|
git -C "${CALC_REPO}" diff feat/ingglish-priority-toggle -- index.html calc/styles.css calc/coderain.js config.default.js manifest.json > "${PATCH_2}"
|
|
echo "[2/2] Verifying exported patches are non-empty and syntactically valid..."
|
|
test -s "${PATCH_1}"
|
|
test -s "${PATCH_2}"
|
|
echo "[OK] Exported clean upstream-ready patches:"
|
|
echo " - ${PATCH_1} ($(wc -c < "${PATCH_1}") bytes)"
|
|
echo " - ${PATCH_2} ($(wc -c < "${PATCH_2}") bytes)"
|
|
exit 0
|
|
fi
|
|
|
|
if [[ "${MODE}" == "--verify-clean-apply" ]]; then
|
|
TMP_WT="/tmp/haiperdohp-patch-verify-$$"
|
|
trap 'git -C "${CALC_REPO}" worktree remove --force "${TMP_WT}" || rm -rf "${TMP_WT}"' EXIT
|
|
git -C "${CALC_REPO}" worktree add --detach "${TMP_WT}" feat/ingglish-aq-corpus
|
|
echo "[1/2] Verifying Layer 2 patch (0001-feat-calc-ingglish-priority-toggle.patch) applies cleanly on feat/ingglish-aq-corpus..."
|
|
git -C "${TMP_WT}" apply --check "${PATCH_1}"
|
|
git -C "${TMP_WT}" apply "${PATCH_1}"
|
|
echo "[2/2] Verifying Layer 3 patch (0002-feat-ui-group3-homepage-parity-and-haiperdohpjematreeah-branding.patch) applies cleanly on top of Layer 2..."
|
|
git -C "${TMP_WT}" apply --check "${PATCH_2}"
|
|
git -C "${TMP_WT}" apply "${PATCH_2}"
|
|
echo "[OK] Both Layer 2 and Layer 3 patches apply 100% cleanly on top of upstream + feat/ingglish-aq-corpus!"
|
|
exit 0
|
|
fi
|
|
|
|
echo "[ERROR] Unknown mode: ${MODE} (expected --export-patches or --verify-clean-apply)" >&2
|
|
exit 2
|