This repository uses pre-commit to enforce code formatting and secret scanning before each commit.
- Python 3.x
pip- For C/C++ formatting:
clang-format(optional — pre-commit will install it via the mirror hook)
-
Install pre-commit:
pip install pre-commit
-
Install the hooks into your local git repo:
pre-commit install
This adds a
.git/hooks/pre-commitscript that runs automatically on everygit commit.
| Hook | What it does |
|---|---|
autopep8 |
Auto-formats Python files to PEP 8 style (max line length 79). Excludes tools/submission/power/power_checker.py. |
clang-format |
Auto-formats C and C++ files using the repo's .clang-format style file. |
gitleaks |
Scans for hardcoded secrets, API keys, and credentials before they are committed. |
Once installed, hooks run automatically on git commit. If a hook modifies files (e.g., autopep8 reformats a Python file), the commit is aborted so you can review the changes, then re-stage and commit:
git add <reformatted files>
git commit -m "your message"Run all hooks against all files:
pre-commit run --all-filesRun a specific hook:
pre-commit run autopep8
pre-commit run clang-format
pre-commit run gitleaksIn exceptional cases you can bypass hooks with:
git commit --no-verify -m "your message"Use this sparingly — the hooks exist to keep the codebase consistent and secrets-free.
To update hook versions to the latest revisions specified in .pre-commit-config.yaml:
pre-commit autoupdate