mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-04-23 11:28:12 +02:00
Add a repo-local Codex hook setup under `.codex/` so trusted Codex users get pre-commit guardrails automatically in this repository. The hook intercepts Bash-based `git commit` tool calls and first runs the deterministic repo-policy focus checks against the staged commit snapshot so invariant violations are reported before formatting. If those checks pass, the hook runs `./devtools/format-code.sh --git-changed`, skips unrelated Git commands, allows commits when `clang-format-18` is unavailable, skips formatting when no tracked `.c` or `.h` files changed, and blocks partial-staging cases or real formatter failures. When formatting changes files, the hook re-stages only the tracked files that were already part of the pending commit. Add `devtools/list-git-changed-c-h-files.sh` so the hook and formatter share one source of truth for tracked changed `.c` and `.h` files. With the help of AI-Agents: Codex
Codex Repo Setup
This repository ships a repo-local Codex hook configuration for trusted projects.
What it does
- Enables Codex hooks for this repository via
.codex/config.toml - Runs
.codex/pre_commit_format_gate.shbefore Bash-basedgit commitcommands - Runs the deterministic repo-policy focus checks first against the staged commit snapshot
- If those invariants fail, the hook exits early and prints the specific failures for the agent to fix
- The hook runs
./devtools/format-code.sh --git-changed - If
clang-format-18is not installed, the hook allows the commit without blocking - If no tracked
.cor.hfiles have changed, the hook skips formatting work - If formatting fails, the
git committool call is blocked and Codex is told to fix formatting first - If formatting updates
.cor.hfiles, the hook stages those tracked formatter updates automatically and then allows the commit - If partially staged
.cor.hfiles are present, the hook blocks because auto-restaging would not be safe
Requirements
- The repository must be trusted so Codex loads
.codex/config.toml - Codex hooks must be available in your Codex build
Scope
This affects Codex users working in this repository. It does not replace normal project review or CI checks, and it does not affect contributors who are not using Codex.