# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2025 ai-ad4 and the FreePDFEditor contributors # Pre-commit hooks for FreePDFEditor contributors (ยง13.2). Install with # `pre-commit install` after cloning. CI runs the same hooks so a missed local # run is caught, not lost. # Pre-commit itself is optional; the hooks it runs (clang-format, gitleaks, # reuse) are the contract. If a contributor doesn't use pre-commit, CI still # enforces all of these. repos: - repo: local hooks: - id: clang-format name: clang-format entry: bash -c 'command -v clang-format >/dev/null && find src spike test -name "*.cpp" -o -name "*.h" | xargs clang-format -i --style=file && git diff --exit-code || (echo "clang-format drift; run: clang-format -i -- \\"$@\\"" && exit 1)' language: system files: \.(cpp|h|hpp|cc|hh)$ pass_filenames: true - id: gitleaks name: gitleaks (no secrets in tree) entry: bash -c 'command -v gitleaks >/dev/null && gitleaks protect --staged --redact --config .gitleaks.toml || (echo "gitleaks not installed; install it or rely on CI" && exit 1)' language: system pass_filenames: false - id: reuse-lint name: reuse lint (SPDX compliance) entry: bash -c 'command -v reuse >/dev/null && reuse lint || (echo "reuse tool not installed; pip install reuse" && exit 1)' language: system pass_filenames: false - id: no-tabs-in-source name: no tabs in C++ source entry: bash -c 'grep -rnP "\t" src spike test --include=*.cpp --include=*.h --include=*.hpp && (echo "tabs found; use spaces" && exit 1) || exit 0' language: system files: \.(cpp|h|hpp|cc|hh)$ pass_filenames: false