mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 06:48:54 +00:00
32 lines
No EOL
888 B
Bash
Executable file
32 lines
No EOL
888 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# Move this file to the .git/hooks directory of the project
|
|
|
|
# Define the directory containing the hooks
|
|
HOOK_DIRECTORY="./git-hooks/backend/hooks"
|
|
|
|
# Define the list of hooks you want to execute
|
|
declare -a USED_HOOKS=(
|
|
"compile-go"
|
|
"db-schema"
|
|
"lint-go"
|
|
)
|
|
|
|
# Iterate over all files in the directory
|
|
for SCRIPT in "$HOOK_DIRECTORY"/*; do
|
|
# Extract just the filename from the path
|
|
FILENAME=$(basename "$SCRIPT")
|
|
|
|
# Check if the filename is in the list
|
|
for TARGET in "${USED_HOOKS[@]}"; do
|
|
if [[ "$FILENAME" == "$TARGET" ]]; then
|
|
# Execute the script, even if it doesn't have execute permissions
|
|
bash "$SCRIPT"
|
|
if [[ $? -ne 0 ]]; then
|
|
# Exit if script fails
|
|
exit 1
|
|
fi
|
|
break # Break inner loop since script was found and executed
|
|
fi
|
|
done
|
|
done |