Created
June 25, 2023 10:56
-
-
Save KingMob/d338dcc293cb0e4852495aae93b821d0 to your computer and use it in GitHub Desktop.
git pre-commit hook that runs a script when project.clj file has been modified
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
#!/usr/bin/env bash | |
# Move this to .git/hooks/pre-commit | |
# echo "Running pre-commit hook..." | |
# Check if project.clj file has been modified | |
if git diff --cached --name-only | grep -q "^project.clj$"; then | |
echo "project.clj modified, running lein-to-deps" | |
repo_root=$(git rev-parse --show-toplevel) | |
# Check the exit status of the script | |
if ! "$repo_root"/deps/lein-to-deps; then | |
echo "lein-to-deps script failed. Aborting commit." | |
exit 1 | |
fi | |
fi | |
# If the "lein-to-deps" script succeeded, | |
# allow the commit to proceed | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should also make a pre-merge-commit script that invokes this for merges, like: