razor-tooling/.githooks/pre-commit

16 строки
459 B
Bash
Executable File

#!/bin/sh
LC_ALL=C
# Select files to format
FILES=$(git show --name-only --pretty="")
[ -z "$FILES" ] && exit 0
# Format all selected files with dotnet-format
echo "dotnet-format: Formatting changed source files.."
echo "$FILES" | cat | xargs | sed -e 's/ /,/g' | xargs dotnet-format --folder . --include >/dev/null
echo "dotnet-format: $(git diff --cached --numstat | wc -l) file(s) formatted."
# Add files to staging
echo "$FILES" | xargs git add
exit 0