Last active
November 12, 2022 14:53
-
-
Save benmatselby/0434e99471ea1bd071d9fff28e2a0231 to your computer and use it in GitHub Desktop.
Example pre-commit hook
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 | |
# | |
# Git pre-commit hook | |
# | |
# Colours https://misc.flogisoft.com/bash/tip_colors_and_formatting | |
reset=$'\e[0m' | |
red=$'\e[1;31m' | |
## | |
# The Makefile target runner | |
## | |
function runTarget { | |
target="${1}" | |
printf '\n🏃♀️ [EXEC] Running target: %s\n' "${target}" | |
if ! make "${target}"; then | |
printf '🔴 [FAIL] %s\n' "${target}" | |
exit 1 | |
fi | |
printf '\n\n\n' | |
} | |
## | |
# General targets irrelevant of changes made. | |
# - Must be quick | |
# - Run for many areas of the codebase | |
## | |
TARGETS=( | |
lint | |
test | |
) | |
for target in "${TARGETS[@]}"; do runTarget "${target}"; done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment