home/.githooks/pre-push

18 lines
578 B
Plaintext
Raw Normal View History

2024-10-23 23:32:12 +02:00
#!/bin/bash
2025-01-12 18:08:25 +01:00
# check for WIP commits
2024-10-23 23:32:12 +02:00
wips=$(git log --oneline --no-decorate | grep -i wip )
2024-10-23 23:54:46 +02:00
wips_n=$(echo "$wips" | wc -l)
2025-01-30 09:18:57 +01:00
LOCKFILE="$PWD/.git/.githook.allow_wip"
2024-10-23 23:32:12 +02:00
2025-01-30 09:18:57 +01:00
# This checks if neither lockfile exists AND wips is non-empty
if [[ ! -f $LOCKFILE && -n "$wips" ]]; then
2025-01-30 09:18:57 +01:00
# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty
echo "contains $wips_n WIP commit(s)"
read -p "Really push? (Y/N) " -n 1 -r
case "$REPLY" in
y|Y ) echo -e "\ncontinuing..."; touch $LOCKFILE;;
* ) echo -e "\naborting."; exit 1;;
esac
2024-10-23 23:32:12 +02:00
fi