# Pre-commit hooks configuration for Hixl
# Install: pip install pre-commit && pre-commit install
# Run manually: pre-commit run --all-files
# Note: clang-format should already be available (installed via system packages)
# Exclusions: build artifacts, third_party, etc.

minimum_pre_commit_version: 4.0.0
exclude: ^LICENSES/|\.(html|csv|svg)$

default_stages: [pre-commit]
ci:
  autofix_prs: false
  autoupdate_schedule: monthly

repos:
  # pre-commit 基础检查
  - repo: https://gitcode.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
        args: ["--allow-multiple-documents"]
      - id: check-added-large-files
      - id: check-merge-conflict
      - id: detect-private-key
      - id: check-json

  # C++ 代码格式化检查
  - repo: https://gitcode.com/pre-commit-clang/mirrors-clang-format
    rev: v18.1.8
    hooks:
      - id: clang-format
        types_or: [ c++, c ]

  # Python 代码检查
  - repo: https://gitcode.com/gh_mirrors/ru/ruff-pre-commit
    rev: v0.14.14
    hooks:
      - id: ruff-check
        args: ["--output-format", "github", "--fix"]
        types: [python]
        exclude: '^(.agents/)'
      - id: ruff-format
        types: [python]
        exclude: '^(.agents/|benchmarks/)'

  # 拼写检查
  - repo: https://gitcode.com/gh_mirrors/co/codespell
    rev: v2.4.1
    hooks:
      - id: codespell
        args: [ '--ignore-words-list=CANN,cann,alog,CLOS,nd,inout' ]
        exclude: '^(.agents/)'

  # OAT 合规性检查 (Open Source Audit Tool)
  - repo: local
    hooks:
      - id: oat-check
        name: OAT Compliance Check
        entry: bash scripts/oat_check.sh
        language: system
        pass_filenames: true
        types: [ file ]
        stages: [ pre-commit ]
        verbose: true