Skip to content

Instantly share code, notes, and snippets.

@jonsmithers
Last active October 11, 2019 01:10
Show Gist options
  • Save jonsmithers/5c0b90ba793845cdc949b872afaff937 to your computer and use it in GitHub Desktop.
Save jonsmithers/5c0b90ba793845cdc949b872afaff937 to your computer and use it in GitHub Desktop.
Prohibit WIP commits
#!/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