Files
watermarks-remover/.pre-commit-hooks.yaml
T
a3b414654f feat: add pre-commit hook integration for staged-file checking/cleaning (#138)
CI gating for AI provenance marks already exists (audit_dir.py's -j
concurrency + SARIF export from #101), but that only runs after a
marked file has already been committed and pushed. Catch it at commit
time instead, using git's own hook point.

Adds two hooks via .pre-commit-hooks.yaml:
- watermarks-remover-check: fails the commit and lists findings when
  staged files carry AI/C2PA marks. Wraps audit_lib.scan_file() /
  is_actionable() -- the exact per-file logic audit_dir.py already
  uses for CI, so the pre-commit gate and the CI gate agree on what
  counts as actionable.
- watermarks-remover-clean (opt-in): rewrites staged files in place by
  shelling out to clean_file.py --in-place per file (no duplicated
  cleaning logic), then exits 1 so the developer reviews the diff and
  re-stages -- the same convention as auto-fixing hooks like ruff --fix.

.pre-commit-hooks.yaml needed an explicit allow-rule in the deny-by-
default .gitignore, same as every other root-level config file already
listed there.

Closes #135

Co-authored-by: Guillaume Meyer (The Opinionated Man) <1385518+guillaumemeyer@users.noreply.github.com>
2026-08-18 07:26:58 -07:00

17 lines
626 B
YAML

- id: watermarks-remover-check
name: watermarks-remover check
description: Fail the commit if staged files carry AI/C2PA provenance marks.
entry: python3 service/scripts/check_staged.py
language: system
stages: [pre-commit]
- id: watermarks-remover-clean
name: watermarks-remover clean (auto-fix)
description: >-
Strip AI/C2PA provenance marks from staged files in place. Opt-in: this
rewrites file contents, so add it only if you want staged files cleaned
automatically rather than just failing the commit.
entry: python3 service/scripts/clean_staged.py
language: system
stages: [pre-commit]