repos:
- repo: local
  hooks:
  - id: invar-md-protected
    name: INVAR.md Protection
    entry: bash -c 'if git diff --cached --name-only | grep -q "^INVAR.md$"; then
      echo "Warning - INVAR.md was modified directly. Use git commit --no-verify if
      intentional."; exit 1; fi'
    language: system
    pass_filenames: false
    stages:
    - pre-commit
  - id: invar-guard
    name: Invar Guard
    entry: bash
    args:
    - -c
    - "RULE_FILES=\"rule_meta.py rules.py contracts.py purity.py pyproject.toml\"\n\
      STAGED=$(git diff --cached --name-only)\nFULL=false\nfor f in $RULE_FILES; do\n\
      \  if echo \"$STAGED\" | grep -qE \"(^|/)${f}$\"; then FULL=true; break; fi\n\
      done\nif [ \"$FULL\" = true ]; then\n  echo \"\u26A0\uFE0F  Rule change detected\
      \ - running FULL guard\"\n  invar guard\nelse\n  invar guard --changed\nfi\n"
    language: system
    pass_filenames: false
    stages:
    - pre-commit
    types:
    - python
