Created
April 21, 2015 23:10
-
-
Save KeyboardCowboy/8694a9caeb3702d6505c to your computer and use it in GitHub Desktop.
Blastr Git Commit Message Hook for Jira Comments
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 | |
# INSTRUCTIONS | |
# | |
# 1. Copy .git/hooks/commit-msg.sample to .git/hooks/commit-msg | |
# 2. Replace the contents of commit-msg with this file | |
# | |
# Automatically add ticket numbers to commit messages using branch names. | |
# | |
# Branches should be in the format [username]-[issue #]-[short-desc] | |
# | |
# Ex. kc-8-pub7-update | |
# Jira project name | |
JIRA_PROJ="BLREDES" | |
# Get the branch name | |
NAME=$(git branch | grep '*' | sed 's/* //') | |
# Grab the ticket string out of the branch name. | |
TICKET=$(echo $NAME | grep -o '\-[0-9]*\-') | |
# Strip off the hyphens to get the issue number. | |
TICKET="${TICKET:1:${#TICKET}-2}" | |
# Prepend the ticket number to the commit message with the proper JIRA format. | |
echo "$JIRA_PROJ-$TICKET #comment "$(cat "$1") > "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment