Skip to content

Commit

Permalink
discard non-sipified directories in prepare_commit and verify_indent
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 30, 2024
1 parent e8b702b commit 5b60c23
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
19 changes: 12 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
exclude: |
(?x)^(
python/.*/auto_\w+/.*.py|
external/.*|
tests/testdata/script_with_error.py
)$
fail_fast: false

repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
exclude: |
(?x)^(
src/core/.*|
src/gui/.*|
src/analysis/.*|
src/3d/.*
)$
# if adding directory handled by clang-format
# you need to adapt prepare_commit and verify_indentation scripts accordingly
hooks:
- id: clang-format
types_or: [c++, c, c#]
exclude: |
(?x)^(
src/core/.*|
src/gui/.*|
src/analysis/.*|
src/3d/.*|
src/server/.*|
tests/code_layout/sipify/sipifyheader.h
)$
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
Expand Down
16 changes: 9 additions & 7 deletions scripts/prepare_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ for f in $MODIFIED; do
;;
esac

m=$f.$REV.prepare

cp "$f" "$m"
ASTYLEPROGRESS=" [$i/$N]" astyle.sh "$f"
if diff -u "$m" "$f" >>"$ASTYLEDIFF"; then
# no difference found
rm "$m"
# only run astyle on sipified directories, others are handled by clang-format (see .pre-commit-config.yaml)
if [[ $f =~ "^src/(core|gui|analysis|3d|server)" ]]; then
m=$f.$REV.prepare
cp "$f" "$m"
ASTYLEPROGRESS=" [$i/$N]" astyle.sh "$f"
if diff -u "$m" "$f" >>"$ASTYLEDIFF"; then
# no difference found
rm "$m"
fi
fi
done

Expand Down
17 changes: 10 additions & 7 deletions scripts/verify_indentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ for f in $FILES; do
;;
esac

m="$f.prepare"
cp "$f" "$m"
astyle.sh "$f"
if diff -u "$m" "$f" >>$ASTYLEDIFF; then
rm "$m"
else
echo "File $f is not styled properly."
# only run astyle on sipified directories, others are handled by clang-format (see .pre-commit-config.yaml)
if [[ $f =~ "^src/(core|gui|analysis|3d|server)" ]]; then
m="$f.prepare"
cp "$f" "$m"
astyle.sh "$f"
if diff -u "$m" "$f" >>$ASTYLEDIFF; then
rm "$m"
else
echo "File $f is not styled properly."
fi
fi
done

Expand Down

0 comments on commit 5b60c23

Please sign in to comment.