forked from mauro-andre/pyodmongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
37 lines (29 loc) · 891 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
29
30
31
32
33
34
35
36
37
#!/bin/sh
# Path to your virtual environment
VENV_DIR="venv"
# Check if the virtual environment directory exists
if [ -d "$VENV_DIR" ]; then
# Activate the virtual environment
. "$VENV_DIR/bin/activate"
else
echo "Virtual environment not found at $VENV_DIR"
exit 1
fi
# Run black formatter on specified directories
black pyodmongo tests
# Check if black made any changes
if ! git diff --exit-code; then
echo "Black formatting made changes. Please add the changes and commit again."
exit 1
fi
# Update requirements.txt
pip freeze > requirements.txt
# Check if requirements.txt was modified
if ! git diff --exit-code requirements.txt; then
echo "requirements.txt was updated. Please add the changes and commit again."
exit 1
fi
# Add requirements.txt to the commit
git add requirements.txt
# If everything is formatted correctly, allow the commit
exit 0