-
-
Save jcf/122159 to your computer and use it in GitHub Desktop.
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
#!/opt/local/bin/bash | |
# .git/hooks/commit-msg | |
exec < /dev/tty | |
commit_message=$1 | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
branch=${ref#refs/heads/} | |
# Exit if commit message empty | |
if [[ ! -n $(grep '^[^#]' "$1" | sed -e 's/^ *//g;s/ *$//g') ]]; then | |
echo >&2 Aborting commit due to empty commit message. | |
exit 1 | |
fi | |
# Check branch name is in the format 123-ticket-name | |
if [[ $branch =~ ^([0-9]+)-.*$ ]]; then | |
lighthouse_ticket=${BASH_REMATCH[1]} | |
echo "Update state of ticket #${lighthouse_ticket}? " | |
echo "(o)pen" | |
echo "(h)old" | |
echo "(r)esolved" | |
echo "Hit return to use the existing state: " | |
state="" | |
read state_selection | |
case $state_selection in | |
"o") | |
state=" state:open" | |
;; | |
"h") | |
state=" state:hold" | |
;; | |
"r") | |
state=" state:resolved" | |
;; | |
esac | |
echo >&2 "[#${lighthouse_ticket}${state}]" >> "$1" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment