home/.githooks/pre-push

21 lines
755 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)
LOCKFILE=/tmp/githook.allow_wip
2024-10-23 23:32:12 +02:00
if [[ ! -f $LOCKFILE && -n "$wips" ]]; then
2024-10-23 23:32:12 +02:00
# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty
2024-10-23 23:54:46 +02:00
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;;
2024-10-23 23:54:46 +02:00
* ) echo -e "\naborting."; exit 1;;
2024-10-23 23:32:12 +02:00
esac
fi
2025-01-12 18:08:25 +01:00
# git-lfs stuff
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; }
git lfs pre-push "$@"