Last active
October 11, 2019 01:10
-
-
Save jonsmithers/5c0b90ba793845cdc949b872afaff937 to your computer and use it in GitHub Desktop.
Prohibit WIP commits
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
#!/bin/bash | |
read -r local_ref local_sha remote_ref remote_sha | |
check_for_wip_commits() { | |
if [[ "$remote_ref" != 'refs/heads/master' ]]; then | |
return | |
fi | |
commits=$(git log --format=%s "$remote_sha".."$local_sha") | |
local IFS=$'\n' | |
for commit in $commits; do | |
for pattern in "^wip[: ]" " wip$"; do | |
if echo "$commit" | grep -i --quiet "$pattern"; then | |
echo "(╯°□°)╯︵ ┻━┻" | |
echo "The following appears to be a WIP commit: \"${commit}\"." | |
echo "Please don't push WIP commits to master. Ask a team member how to squash and reword WIP commits." | |
exit 1 | |
fi | |
done | |
done | |
} | |
check_for_wip_commits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment