Guard on more exotic filenames.
parent
07eb1fa382
commit
963283b74e
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
FORMAT_FILES=$(
|
||||
git --no-pager diff --name-status --no-color --cached | \
|
||||
awk '$1 != "D" && $2 ~ /\.c$|\.h$/ {print $NF}'
|
||||
STAGED=$(
|
||||
git --no-pager diff --name-only --no-color --cached --diff-filter=d |
|
||||
# Remove quotations used to surrounding filenames with special characters.
|
||||
sed -e "s/^\"//" -e "s/\"$//g"
|
||||
)
|
||||
|
||||
if [ -n "$FORMAT_FILES" ]; then
|
||||
clang-format -i "$FORMAT_FILES"
|
||||
git add "$FORMAT_FILES"
|
||||
TARGETS=()
|
||||
while IFS= read -r FILENAME
|
||||
do
|
||||
if [[ "$FILENAME" =~ .*\.c ]] || [[ "$FILENAME" == .*\.h ]]; then
|
||||
TARGETS+=("${FILENAME}")
|
||||
fi
|
||||
done <<< "$STAGED"
|
||||
|
||||
if (( ${#TARGETS[@]} )); then
|
||||
clang-format -i "${TARGETS[@]}"
|
||||
git add "${TARGETS[@]}"
|
||||
fi
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
FORMAT_FILES=$(
|
||||
git --no-pager diff --name-status --no-color --cached | \
|
||||
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
|
||||
STAGED=$(
|
||||
git --no-pager diff --name-only --no-color --cached --diff-filter=d |
|
||||
# Remove quotations used to surrounding filenames with special characters.
|
||||
sed -e "s/^\"//" -e "s/\"$//g"
|
||||
)
|
||||
|
||||
if [ -n "$FORMAT_FILES" ]; then
|
||||
mix format "$FORMAT_FILES"
|
||||
git add "$FORMAT_FILES"
|
||||
TARGETS=()
|
||||
while IFS= read -r FILENAME
|
||||
do
|
||||
if [[ "$FILENAME" =~ .*\.exs? ]]; then
|
||||
TARGETS+=("${FILENAME}")
|
||||
fi
|
||||
done <<< "$STAGED"
|
||||
|
||||
if (( ${#TARGETS[@]} )); then
|
||||
mix format "${TARGETS[@]}"
|
||||
git add "${TARGETS[@]}"
|
||||
fi
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
FORMAT_FILES=$(
|
||||
git --no-pager diff --name-status --no-color --cached | \
|
||||
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
|
||||
STAGED=$(
|
||||
git --no-pager diff --name-only --no-color --cached --diff-filter=d |
|
||||
# Remove quotations used to surrounding filenames with special characters.
|
||||
sed -e "s/^\"//" -e "s/\"$//g"
|
||||
)
|
||||
|
||||
if [ -n "$FORMAT_FILES" ]; then
|
||||
prettier --write "$FORMAT_FILES"
|
||||
git add "$FORMAT_FILES"
|
||||
TARGETS=()
|
||||
while IFS= read -r FILENAME
|
||||
do
|
||||
if [[ "$FILENAME" =~ .*\.jsx? ]] || [[ "$FILENAME" == .*\.tsx? ]]; then
|
||||
TARGETS+=("${FILENAME}")
|
||||
fi
|
||||
done <<< "$STAGED"
|
||||
|
||||
if (( ${#TARGETS[@]} )); then
|
||||
prettier --write "${TARGETS[@]}"
|
||||
git add "${TARGETS[@]}"
|
||||
fi
|
||||
|
|
|
@ -1,22 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
MIX_FILES=$(
|
||||
git --no-pager diff --name-status --no-color --cached | \
|
||||
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
|
||||
STAGED=$(
|
||||
git --no-pager diff --name-only --no-color --cached --diff-filter=d |
|
||||
# Remove quotations used to surrounding filenames with special characters.
|
||||
sed -e "s/^\"//" -e "s/\"$//g"
|
||||
)
|
||||
|
||||
if [ -n "$MIX_FILES" ]; then
|
||||
mix format "$MIX_FILES"
|
||||
git add "$MIX_FILES"
|
||||
MIX_TARGETS=()
|
||||
WEB_TARGETS=()
|
||||
while IFS= read -r FILENAME
|
||||
do
|
||||
if [[ "$FILENAME" =~ .*exs? ]]; then
|
||||
MIX_TARGETS+=("${FILENAME}")
|
||||
elif [[ "$FILENAME" =~ .*jsx? ]] || [[ "$FILENAME" =~ .*tsx? ]]; then
|
||||
WEB_TARGETS+=("${FILENAME}")
|
||||
fi
|
||||
done <<< "$STAGED"
|
||||
|
||||
if (( ${#MIX_TARGETS[@]} )); then
|
||||
mix format "${MIX_TARGETS[@]}"
|
||||
git add "${MIX_TARGETS[@]}"
|
||||
fi
|
||||
|
||||
WEB_FILES=$(
|
||||
git --no-pager diff --name-status --no-color --cached | \
|
||||
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
|
||||
)
|
||||
|
||||
if [ -n "$WEB_FILES" ]; then
|
||||
prettier --write "$WEB_FILES"
|
||||
git add "$WEB_FILES"
|
||||
if (( ${#WEB_TARGETS[@]} )); then
|
||||
prettier --write "${WEB_TARGETS[@]}"
|
||||
git add "${WEB_TARGETS[@]}"
|
||||
fi
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
FORMAT_FILES=$(
|
||||
git --no-pager diff --name-status --no-color --cached | \
|
||||
awk '$1 != "D" && $2 ~ /\.py$/ {print $NF}'
|
||||
STAGED=$(
|
||||
git --no-pager diff --name-only --no-color --cached --diff-filter=d |
|
||||
# Remove quotations used to surrounding filenames with special characters.
|
||||
sed -e "s/^\"//" -e "s/\"$//g"
|
||||
)
|
||||
|
||||
if [ -n "$FORMAT_FILES" ]; then
|
||||
black --quiet "$FORMAT_FILES"
|
||||
git add "$FORMAT_FILES"
|
||||
TARGETS=()
|
||||
while IFS= read -r FILENAME
|
||||
do
|
||||
if [[ "$FILENAME" =~ .*\.py ]]; then
|
||||
TARGETS+=("${FILENAME}")
|
||||
fi
|
||||
done <<< "$STAGED"
|
||||
|
||||
if (( ${#TARGETS[@]} )); then
|
||||
black --quiet "${TARGETS[@]}"
|
||||
git add "${TARGETS[@]}"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue