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

View File

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

View File

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

View File

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

View File

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