home/.githooks/pre-push

18 lines
578 B
Bash
Executable File

#!/bin/bash
# check for WIP commits
wips=$(git log --oneline --no-decorate | grep -i wip )
wips_n=$(echo "$wips" | wc -l)
LOCKFILE="$PWD/.git/.githook.allow_wip"
# This checks if neither lockfile exists AND wips is non-empty
if [[ ! -f $LOCKFILE && -n "$wips" ]]; then
# 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
fi