Skip to content

Instantly share code, notes, and snippets.

@martinwheeler
Created February 13, 2019 04:46
Show Gist options
  • Save martinwheeler/edefab7d84389df251713b4ece33244e to your computer and use it in GitHub Desktop.
Save martinwheeler/edefab7d84389df251713b4ece33244e to your computer and use it in GitHub Desktop.
#!/bin/sh
# Gets the current users branch
currentBranch="$(git branch | grep \* | cut -d ' ' -f2)"
# Only run if the user is on beta / beta-dev / master branches
if [ "$currentBranch" = "beta" ] || [ "$currentBranch" = "beta-dev" ] || [ "$currentBranch" = "master" ] ; then
# Needed to capture keyboard input during the pre-push stage
# https://stackoverflow.com/questions/3417896/how-do-i-prompt-the-user-from-within-a-commit-msg-hook
exec < /dev/tty
while true; do
# Simple yes/no input check
read -p "Would you like to update the changelog/version number (y/n)? " -n 1 -r
echo
# Default to yes
if [[ "$REPLY" = "" ]]
then
REPLY='Y'
fi
case $REPLY in
[Yy] ) yarn release; break;;
[Nn] ) break;;
* ) echo "\r\nPlease answer y or n for yes or no.";;
esac
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment