From 87f3f908bf2847955aa49e88025bb8ebff80a0c4 Mon Sep 17 00:00:00 2001 From: vasilito Date: Sun, 12 Jul 2026 12:20:29 +0300 Subject: [PATCH] phase 9.1-9.2: add commit-msg hook + consolidate tool docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the commit-msg hook promised in HOOKS.md since Round 5. The hook auto-prepends the current Red Bear development phase (e.g. 'phase 8.4:') to commit messages. The phase is detected from the most recent 'phase X.Y:' commit in the git log. Hook behavior: - Normal commit → prepended: 'phase 8.4: my message' - Already has prefix → skipped - Revert message → skipped - Empty/comment → skipped Install: cp local/scripts/commit-msg .git/hooks/commit-msg && chmod +x Updates HOOKS.md with: - commit-msg hook documentation (install, behavior) - Full tool inventory table (10 tools across 9+ rounds) listing each tool's type, purpose, and modes/flags --- local/docs/HOOKS.md | 31 +++++++++++++++++++++++++++++-- local/scripts/commit-msg | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 local/scripts/commit-msg diff --git a/local/docs/HOOKS.md b/local/docs/HOOKS.md index 28e820d20d..a8956c8725 100644 --- a/local/docs/HOOKS.md +++ b/local/docs/HOOKS.md @@ -74,5 +74,32 @@ in `local/scripts/` so operators can opt in by copying it to ## Audit This directory was created in Phase 4.5 (Round 5). The current -hook inventory is just the 1 file above. Future hooks should be -added here as they are created. +hook inventory is: + +| Hook | File | Function | +|------|------|----------| +| pre-push | `local/scripts/pre-push-checks.sh` | Runs 7 pre-flight checks before push | +| commit-msg | `local/scripts/commit-msg` | Auto-prepends `phase X.Y:` to commit messages | +| (server-side) | (gitea admin only) | Pre-receive — defense in depth; not yet implemented | + +## Full Tool Inventory (Round 10) + +The build system has grown organically across 9+ rounds. Here is +the complete tool inventory for reference. + +| Tool | Type | Purpose | Modes | +|------|------|---------|-------| +| `patch-status.sh` | shell | Top-level consolidated report | `--brief`, `--json` | +| `sync-versions.sh` | shell | Cat 0+1+2 version sync | `--check`, `--no-regen`, `--regen-only` | +| `verify-patch-content.sh` | shell↦py | Orphan patch detection | `--strict`, `--report action\|detail`, `--selftest` | +| `verify-fork-versions.sh` | shell | Cat 2 fork supremacy check | diverged mode; `REDBEAR_STRICT_DIVERGED_CHECK=1` | +| `verify-collision-detection.py` | python | Config [[files]] vs installs/files collision | `--strict`, `--selftest` (8 cases) | +| `pre-push-checks.sh` | shell | 7-check pre-push safety net | `--soft` for warn-only | +| `push-fork-branches.sh` | shell | Operator-reviewed fork push | `--execute` for actual push (default=print-only) | +| `unblock-base-push.sh` | shell | Base fork deadlock resolver | `path-a`, `path-b`, `path-c` for 3 operator paths | +| `commit-msg` | shell | Auto-phase-prefix hook | opt-in; install to `.git/hooks/commit-msg` | +| `build-preflight.sh` | shell | Build-time validation | Called by `build-redbear.sh` | + +All scripts are under `local/scripts/` and are designed to be +operator-friendly. Hooks are strictly opt-in per AGENTS.md +"absolutely NEVER DELETE, NEVER IGNORE" rule. diff --git a/local/scripts/commit-msg b/local/scripts/commit-msg new file mode 100755 index 0000000000..e01ac8343d --- /dev/null +++ b/local/scripts/commit-msg @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# commit-msg — Optional commit-msg hook for Red Bear OS. +# Auto-prepends the current development phase to commit messages. +# Usage: +# cp local/scripts/commit-msg .git/hooks/commit-msg +# chmod +x .git/hooks/commit-msg +# The hook is OPT-IN. See local/docs/HOOKS.md. + +set -euo pipefail + +COMMIT_MSG_FILE="$1" +PHASE="" + +# Detect current phase from the most recent "phase X.Y:" commit in log +detect_phase() { + PHASE=$(git log --oneline -50 2>/dev/null | grep -oP 'phase \d+\.\d+' | head -1) + [ -n "$PHASE" ] || PHASE="phase" +} + +detect_phase +FIRST_LINE=$(head -1 "$COMMIT_MSG_FILE" 2>/dev/null) + +# Already has phase prefix or is Revert — skip +echo "$FIRST_LINE" | grep -qE '^(phase [0-9]+\.[0-9]+):' && exit 0 +echo "$FIRST_LINE" | grep -qE '^Revert ' && exit 0 + +# Empty or comment — skip +[ -z "$FIRST_LINE" ] && exit 0 +echo "$FIRST_LINE" | grep -q '^#' && exit 0 + +# Prepend phase +sed -i "1s/^/${PHASE}: /" "$COMMIT_MSG_FILE" +exit 0