Add pre-commit utility

This commit is contained in:
Sameer Rahmani 2022-06-11 18:33:35 +01:00
parent 05fdd9f1b2
commit 182c87a046
2 changed files with 38 additions and 2 deletions

30
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,30 @@
# Apply to all files without commiting:
# pre-commit run --all-files
# Update this file:
# pre-commit autoupdate
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/pocc/pre-commit-hooks
rev: master
hooks:
- id: clang-format
- id: clang-tidy
- id: oclint
- id: uncrustify
- id: cppcheck
- id: cpplint
- id: include-what-you-use

10
builder
View File

@ -273,8 +273,14 @@ function release-serene-image() { ## Build and push the Serene docker image for
function setup() { ## Setup the working directory and make it ready for development
rm -rfv "$ME/.git/hooks/pre-commit"
ln -s "$ME/scripts/pre-commit" "$ME/.git/hooks/pre-commit"
if command -v python3 >/dev/null 2>&1; then
pip install pre-commit
pre-commit install
else
error "Python is required to setup pre-commit"
fi
# rm -rfv "$ME/.git/hooks/pre-commit"
# ln -s "$ME/scripts/pre-commit" "$ME/.git/hooks/pre-commit"
}
function scan-build() { ## Runs the `scan-build` utility to analyze the build process