-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update pre-commit hook to use custom script for Alembic checks and en…
…hance environment variable loading
- Loading branch information
Showing
2 changed files
with
13 additions
and
11 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if any command fails | ||
set -e | ||
# Load environment variables if .env exists | ||
if [ -f .env ]; then | ||
export $(cat .env | grep -v '^#' | xargs) | ||
elif [ -f .mockenv ]; then | ||
export $(cat .mockenv | grep -v '^#' | xargs) | ||
fi | ||
|
||
# Run the Alembic check command | ||
# Run alembic check | ||
alembic check | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error: Uncommitted Alembic upgrade operations detected." | ||
echo "Please generate and commit your migration scripts." | ||
exit 1 | ||
fi | ||
# Store the exit code | ||
exit_code=$? | ||
|
||
echo "Alembic check passed. No new upgrade operations detected." | ||
# Return the alembic check exit code | ||
exit $exit_code |