Skip to content

Commit

Permalink
Make pre-commit hook a local hook
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Nov 8, 2021
1 parent d22ad2c commit b7ebdef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/franzpoeschel/openPMD-api-pre-commit-hooks
rev: aa38b2ad4fae42db05c19de211f43df6a7981bc5
- repo: local
hooks:
- id: clang-format
name: clang-format
description: Clang-format our code base
language: conda
entry: bash ./clang-format.sh --install-clang-format
additional_dependencies: [-c, conda-forge, clang-format-12]
11 changes: 11 additions & 0 deletions clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

if [[ $1 = "--install-clang-format" ]]; then
echo -e "\n\n\n–––––––\nENV:\n––––––––\n\n\n$(env)\n\n\n–––––\nBINS:\n–––––\n\n\n$(ls $CONDA_PREFIX/..)\n\n\n"
ls /usr/bin
fi

find include/ src/ test/ examples/ \
-regextype egrep \
-type f -regex '.*\.(hpp|cpp|hpp\.in)$' \
| xargs /usr/bin/clang-format-12 -i
7 changes: 7 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# I am a conda environment, used for our pre-commit hooks
name: openPMD-api-dev
channels:
- conda-forge
dependencies:
- clang-format-12=12.0.1
- bash=5

0 comments on commit b7ebdef

Please sign in to comment.