chore: add a pre-commit hook to auto format erlang code
This commit is contained in:
parent
09b6648567
commit
af69899619
|
@ -7,3 +7,4 @@ scripts/* text eol=lf
|
|||
*.jpg -text
|
||||
*.png -text
|
||||
*.pdf -text
|
||||
scripts/erlfmt -text
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
files="$(git diff --cached --name-only | grep -E '.*\.erl' || true)"
|
||||
if [[ "${files}" == '' ]]; then
|
||||
exit 0
|
||||
fi
|
||||
files="$(echo -e "$files" | xargs)"
|
||||
# shellcheck disable=SC2086
|
||||
./scripts/erlfmt -c $files
|
|
@ -11,3 +11,7 @@ mkdir -p ".git/hooks"
|
|||
if [ ! -L '.git/hooks/pre-push' ]; then
|
||||
ln -sf '../../scripts/git-hook-pre-push.sh' '.git/hooks/pre-push'
|
||||
fi
|
||||
|
||||
if [ ! -L '.git/hooks/pre-commit' ]; then
|
||||
ln -sf '../../scripts/git-hook-pre-commit.sh' '.git/hooks/pre-commit'
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue