Skip to content

Commit de2de54

Browse files
committed
Add skipping of files using CPP extension in stylish-haskell git hook
1 parent 5006b56 commit de2de54

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.github/workflows/stylish-haskell.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ jobs:
6565
6666
for x in $(git ls-tree --full-tree --name-only -r HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
6767
if [ "${x##*.}" == "hs" ]; then
68-
stylish-haskell -i $x
68+
if grep -qE '^#' $x; then
69+
echo "$x contains CPP. Skipping."
70+
else
71+
stylish-haskell -i $x
72+
fi
6973
fi
7074
done
7175
@@ -78,7 +82,11 @@ jobs:
7882
git fetch origin ${{ github.base_ref }} --unshallow
7983
for x in $(git diff --name-only origin/${{ github.base_ref }}..HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
8084
if [ "${x##*.}" == "hs" ]; then
81-
stylish-haskell -i $x
85+
if grep -qE '^#' $x; then
86+
echo "$x contains CPP. Skipping."
87+
else
88+
stylish-haskell -i $x
89+
fi
8290
fi
8391
done
8492

scripts/githooks/haskell-style-lint

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
#
55
# To set this script as your pre-commit hook, use the following command:
66
#
7-
# ln -s $(git-root)/scripts/githooks/haskell-style-lint $(git-root)/.git/hooks/pre-commit
7+
# ln -s $(git-root)/scripts/githooks/haskell-style-lint $(git rev-parse --git-dir)/hooks/pre-commit
88
#
99

1010
for x in $(git diff --staged --name-only --diff-filter=ACM | tr '\n' ' '); do
1111
if [ "${x##*.}" = "hs" ]; then
12-
stylish-haskell -i "$x"
12+
if grep -qE '^#' "$x"; then
13+
echo "$x contains CPP. Skipping."
14+
else
15+
stylish-haskell -i "$x"
16+
fi
1317
# fail on linting issues
1418
hlint "$x"
1519
fi

0 commit comments

Comments
 (0)