mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-19 14:02:56 +02:00
Why: recent Codex CLI payloads now wrap shell commands as `bash -lc '...'`, so the repo-local pre-commit gate stopped recognizing `git commit` invocations and no longer ran. Impact: the hook now intercepts both direct and shell-wrapped `git commit` commands before the commit proceeds. Before/After: wrapped `git commit` payloads bypassed the gate; now they are detected and processed like direct invocations. Technical Overview: Teach the hook parser to unwrap `bash`, `sh`, and `zsh` launchers that pass commands via `-c` or `-lc`. Recurse into the nested shell command and reuse the existing `git commit` matcher on the extracted simple commands. Document the wrapped-command form in `.codex/README.md` so the expected runtime shape stays visible next to the hook setup. Validation: `bash -n .codex/pre_commit_format_gate.sh`; manual PreToolUse payload smoke tests for direct and wrapped `git commit --help` commands. With the help of AI-Agents: Codex
1.4 KiB
1.4 KiB
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 - Understands both direct
git commit ...invocations and shell-wrapped forms such asbash -lc 'git commit ...' - 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.