Add pre-commit guard on empty state.

pull/12/head
Joshua Potter 2023-12-03 11:32:45 -07:00
parent aa872f7a4f
commit 07eb1fa382
5 changed files with 25 additions and 17 deletions

View File

@ -6,6 +6,7 @@ FORMAT_FILES=$(
awk '$1 != "D" && $2 ~ /\.c$|\.h$/ {print $NF}'
)
if [ -n "$FORMAT_FILES" ]; then
clang-format -i "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi

View File

@ -6,6 +6,7 @@ FORMAT_FILES=$(
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
)
if [ -n "$FORMAT_FILES" ]; then
mix format "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi

View File

@ -6,6 +6,7 @@ FORMAT_FILES=$(
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
)
if [ -n "$FORMAT_FILES" ]; then
prettier --write "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi

View File

@ -6,13 +6,17 @@ MIX_FILES=$(
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
)
if [ -n "$MIX_FILES" ]; then
mix format "$MIX_FILES"
git add "$MIX_FILES"
fi
WEB_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
)
mix format "$MIX_FILES"
if [ -n "$WEB_FILES" ]; then
prettier --write "$WEB_FILES"
git add "$MIX_FILES" "$WEB_FILES"
git add "$WEB_FILES"
fi

View File

@ -6,6 +6,7 @@ FORMAT_FILES=$(
awk '$1 != "D" && $2 ~ /\.py$/ {print $NF}'
)
if [ -n "$FORMAT_FILES" ]; then
black --quiet "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi