Update precommit hooks (#393)
* Add pre-commit * Add clang pre-commit * Install pre-commit in init
This commit is contained in:
parent
3e7aef432f
commit
483f4d04bd
@ -24,14 +24,6 @@ for file in $modified_files; do
|
|||||||
|
|
||||||
git checkout-index --prefix="$tmpdir/" -- $file
|
git checkout-index --prefix="$tmpdir/" -- $file
|
||||||
|
|
||||||
echo "Running clang-format..."
|
|
||||||
$project_folder/tools/git-clang-format $tmpdir/$file
|
|
||||||
CODE=$?
|
|
||||||
|
|
||||||
if [ $CODE -ne 0 ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Do not break header checker
|
# Do not break header checker
|
||||||
echo "Running header checker..."
|
echo "Running header checker..."
|
||||||
$project_folder/tools/header-checker.py $tmpdir/$file $file --amend-year
|
$project_folder/tools/header-checker.py $tmpdir/$file $file --amend-year
|
||||||
@ -39,7 +31,6 @@ for file in $modified_files; do
|
|||||||
if [ $CODE -ne 0 ]; then
|
if [ $CODE -ne 0 ]; then
|
||||||
FAIL=1
|
FAIL=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done;
|
done;
|
||||||
|
|
||||||
return ${FAIL}
|
return ${FAIL}
|
||||||
|
24
.pre-commit-config.yaml
Normal file
24
.pre-commit-config.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v2.3.0
|
||||||
|
hooks:
|
||||||
|
- id: check-yaml
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 22.3.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
args: # arguments to configure black
|
||||||
|
- --line-length=120
|
||||||
|
- --include='\.pyi?$'
|
||||||
|
# these folders wont be formatted by black
|
||||||
|
- --exclude="""\.git |
|
||||||
|
\.__pycache__|
|
||||||
|
build|
|
||||||
|
libs|
|
||||||
|
.cache"""
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
|
rev: v13.0.0
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
4
init
4
init
@ -135,3 +135,7 @@ for hook in $(find $DIR/.githooks -type f -printf "%f\n"); do
|
|||||||
ln -s -f "$DIR/.githooks/$hook" "$DIR/.git/hooks/$hook"
|
ln -s -f "$DIR/.githooks/$hook" "$DIR/.git/hooks/$hook"
|
||||||
echo "Added $hook hook"
|
echo "Added $hook hook"
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
# Install precommit hook
|
||||||
|
python3 -m pip install pre-commit
|
||||||
|
python3 -m pre_commit install
|
||||||
|
Loading…
Reference in New Issue
Block a user