Skip to content

Commit 4e88d6f

Browse files
Add commit hooks
1 parent f98f83b commit 4e88d6f

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.clang-format

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
BasedOnStyle: LLVM
3+
4+
---
5+
Language: Cpp
6+
PointerAlignment: Left
7+
AllowShortLoopsOnASingleLine: true
8+
9+
# If parameters don't fit on one line format(
10+
# arg1, arg2
11+
# );
12+
AlignAfterOpenBracket: BlockIndent
13+
14+
# Try putting all constructor initializers
15+
# on the next line if they don't fit, but,
16+
# if they also don't fit on the next line,
17+
# make them 1 per line
18+
PackConstructorInitializers: NextLineOnly
19+
20+
# Function calls and init lists try to fit
21+
# args on same line, else all on next line,
22+
# else one arg per line
23+
BinPackArguments: false
24+
AllowAllArgumentsOnNextLine: true
25+
26+
# Don't reflow doxygen comment lines
27+
CommentPragmas: '^\*? ?@'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ CMakeCache.txt
5151
*Makefile
5252
*.cmake
5353
cmake_install.cmake
54+
55+
# Pre-commit files
56+
pre-commit-*.pyz

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/crate-ci/typos
3+
rev: v1.34.0
4+
hooks:
5+
- id: typos
6+
- repo: https://github.com/pre-commit/mirrors-clang-format
7+
rev: v20.1.8
8+
hooks:
9+
- id: clang-format
10+
types_or: [c++, c]

test/CI/install_prehooks.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
PRECOMMIT_VERSION="4.2.0"
4+
PRECOMMIT_PYZ="pre-commit-${PRECOMMIT_VERSION}.pyz"
5+
PRECOMMIT_URL="https://github.com/pre-commit/pre-commit/releases/download/v${PRECOMMIT_VERSION}/${PRECOMMIT_PYZ}"
6+
7+
if ! [[ -f "$PRECOMMIT_PYZ" ]]; then
8+
wget --no-verbose --show-progress "$PRECOMMIT_URL"
9+
chmod u+x "$PRECOMMIT_PYZ"
10+
fi
11+
PRECOMMIT=${PWD}/$PRECOMMIT_PYZ
12+
13+
#Go to git repo's root directory
14+
cd $(git rev-parse --show-toplevel)
15+
16+
$PRECOMMIT install

0 commit comments

Comments
 (0)