Simply pre-commit hooks.

pull/12/head
Joshua Potter 2023-12-03 11:24:45 -07:00
parent 9d18552218
commit 7849e3fcdd
5 changed files with 23 additions and 37 deletions

View File

@ -1,13 +1,11 @@
#!/usr/bin/env bash
set -e
filesToFormat=$(
FORMAT_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.c$|\.h$/ {print $NF}'
)
for path in $filesToFormat
do
clang-format -i "$path"
git add "$path"
done
clang-format -i "$FORMAT_FILES"
git add "$FORMAT_FILES"

View File

@ -1,13 +1,11 @@
#!/usr/bin/env bash
set -e
filesToFormat=$(
FORMAT_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
)
for path in $filesToFormat
do
mix format "$path"
git add "$path"
done
mix format "$FORMAT_FILES"
git add "$FORMAT_FILES"

View File

@ -1,13 +1,11 @@
#!/usr/bin/env bash
set -e
filesToFormat=$(
FORMAT_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
)
for path in $filesToFormat
do
prettier --write "$path"
git add "$path"
done
prettier --write "$FORMAT_FILES"
git add "$FORMAT_FILES"

View File

@ -1,24 +1,18 @@
#!/usr/bin/env bash
set -e
mixFiles=$(
MIX_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
)
for path in $mixFiles
do
mix format "$path"
git add "$path"
done
webFiles=$(
WEB_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
)
for path in $webFiles
do
prettier --write "$path"
git add "$path"
done
mix format "$MIX_FILES"
prettier --write "$WEB_FILES"
git add "$MIX_FILES" "$WEB_FILES"

View File

@ -1,13 +1,11 @@
#!/usr/bin/env bash
set -e
filesToFormat=$(
FORMAT_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.py$/ {print $NF}'
)
for path in $filesToFormat
do
black --quiet "$path"
git add "$path"
done
black --quiet "$FORMAT_FILES"
git add "$FORMAT_FILES"