Add .loop-build harness and IntelliJ project configuration files

This commit is contained in:
2026-02-25 01:18:49 +08:00
commit 6f02ef607f
27 changed files with 1792 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
if [[ ! -d "$ROOT_DIR/.git" ]]; then
echo "[apply_patch][ERROR] no git repository available"
exit 2
fi
patch_tmp=$(mktemp)
cleanup() { rm -f "$patch_tmp"; }
trap cleanup EXIT
if [[ $# -ge 1 ]]; then
cp "$1" "$patch_tmp"
else
cat > "$patch_tmp"
fi
if [[ ! -s "$patch_tmp" ]]; then
echo "[apply_patch][ERROR] patch is empty"
exit 2
fi
if ! git -C "$ROOT_DIR" apply --check "$patch_tmp" >/dev/null 2>&1; then
echo "[apply_patch][ERROR] patch does not apply cleanly"
exit 2
fi
file_count=$(git -C "$ROOT_DIR" apply --numstat "$patch_tmp" | awk '$3 != "" {print $3}' | sort -u | wc -l | tr -d ' ')
if (( file_count > 2 )); then
echo "[apply_patch][BLOCK] patch touches $file_count files; max is 2 per step."
exit 2
fi
git -C "$ROOT_DIR" apply "$patch_tmp"
echo "[apply_patch][OK] patch applied"