Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BasedOnStyle: Google
ColumnLimit: 120
DerivePointerAlignment: false
PointerAlignment: Left
AllowShortFunctionsOnASingleLine: Inline
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.5
hooks:
- id: clang-format
args: [-style=file]
files: '\.(cpp|hpp|c|h|cc|hh)$'
45 changes: 45 additions & 0 deletions docs/manual/PreCommitSetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### Code Formatting and Pre-commit Hooks

This project uses [pre-commit](https://pre-commit.com) to ensure code quality and consistent formatting.

To set it up:

1. **Create a Virtual Environment**:
Create and activate a Python virtual environment:
```bash
python3 -m venv venv
source venv/bin/activate
```

2. **Install Development Dependencies**:
Install the required dependencies for building the project:
```bash
pip install -r requirements.txt
```

3. **Install the Git hooks**:

```bash
pre-commit install
```

To update the hooks to their latest versions later:

```bash
pre-commit autoupdate
```

**DO NOT** run. It is not recomended on legacy repositories:

```bash
pre-commit run --all-files
```

The following hooks are used:

* `clang-format` for C/C++ formatting
* `trailing-whitespace` to remove trailing spaces
* `end-of-file-fixer` to ensure files end with a single newline
* `check-added-large-files` to avoid accidentally committing large binaries

All configuration is in `.pre-commit-config.yaml`. The hooks will run automatically every time you commit.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pre-commit==4.2.0
clang-format==20.1.5