forked from python/typeshed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
executable file
·28 lines (24 loc) · 983 Bytes
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
#
# An example hook script that will run flake8, black, and isort
# prior to committing and will stop the commit if there are any
# warnings. Adjust BIN_DIR to the virtual environment where flake8,
# black, and isort are installed.
#
# To enable this hook, copy this file to ".git/hooks".
BIN_DIR=./.venv3/bin
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM | grep .pyi || true)
if test -n "${CHANGED_FILES}" -a -d "${BIN_DIR}"; then
${BIN_DIR}/flake8 ${CHANGED_FILES}
${BIN_DIR}/black --check ${CHANGED_FILES}
${BIN_DIR}/isort --check-only ${CHANGED_FILES}
# Replace the last two lines with the following lines
# if you want to reformat changed files automatically
# before committing. Please note that partial commits
# (git add -p) will not work and will commit the whole
# file!
#
# ${BIN_DIR}/black ${CHANGED_FILES} || true
# ${BIN_DIR}/isort -y ${CHANGED_FILES} || true
# git add ${CHANGED_FILES}
fi