Created
May 17, 2023 07:46
-
-
Save SXHRYU/b3e2cd245999526438a5acdde77424fb to your computer and use it in GitHub Desktop.
pre-commit hook I use for my work. I didn't update the `pre-commit` gist, because it's starting to get VERY different.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias black79="black --line-length 79 --force-exclude '((^.*(\/migrations\/).*\.py)|(.*\.(?!pyi?$)[^.]+$))' --extend-exclude migrations/" | |
alias isort79="isort --multi-line 3 --force-alphabetical-sort-within-sections --trailing-comma --combine-as --lines-after-imports 2 --filter-files --extend-skip migrations" | |
alias autoflake79="autoflake --remove-all-unused-imports --ignore-init-module-imports -r -v --in-place --exclude '*/migrations/*'" | |
git diff --quiet --cached --name-only --diff-filter=D | |
start_condition_0=$? | |
git diff --quiet --cached --name-only --diff-filter=ACMR | |
start_condition_1=$? | |
if [ $start_condition_0 = 0 ] && [ $start_condition_1 = 1 ] | |
then | |
echo "---------------isort---------------" | |
isort79 --check $(git diff --cached --name-only --diff-filter=ACMR) | |
isort_status=$? | |
if [ $isort_status != 0 ] | |
then | |
exit $isort_status | |
fi | |
echo "---------------autoflake---------------" | |
autoflake79 --check $(git diff --cached --name-only --diff-filter=ACMR) | |
autoflake_status=$? | |
if [ $autoflake_status != 0 ] | |
then | |
exit $autoflake_status | |
fi | |
echo "---------------black---------------" | |
black79 --check $(git diff --cached --name-only --diff-filter=ACMR) | |
black_status=$? | |
if [ $black_status != 0 ] | |
then | |
exit $black_status | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rev. 2
typo fixes