Files
server/.git-hooks/pre-commit
2025-10-03 15:22:20 -04:00

20 lines
558 B
Bash
Executable File

#!/bin/sh
# Skip hook if this is a merge commit
if [ -f .git/MERGE_HEAD ]; then
exit 0
fi
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
if npx mega-linter-runner --containername "megalinter-incremental" \
--flavor formatters --remove-container --fix --env "'APPLY_FIXES=all'" \
--env "'CLEAR_REPORT_FOLDER=true'" --env "'LOG_LEVEL=warning'" \
--env "'FLAVOR_SUGGESTIONS=false'" --filesonly $FILES; then
echo "$FILES" | xargs git add
exit 0
fi
exit 1