Skip to content

Instantly share code, notes, and snippets.

@rdelandesen
Created May 27, 2017 19:34
Show Gist options
  • Save rdelandesen/b7d18b1247cae6b1cd3ad47bde6ed44b to your computer and use it in GitHub Desktop.
Save rdelandesen/b7d18b1247cae6b1cd3ad47bde6ed44b to your computer and use it in GitHub Desktop.
Commit message with JIRA branch name
#!/bin/sh
#
# Prepend the branch name to the commit message
#
# Example
# # On branch BRA-1_homepage
# git commit -m "Responsive menu"
# # => [BRA-1] Responsive menu
#
# Add this file as [repo]/.git/hooks/prepare-commit-msg
#
NAME=$(git symbolic-ref --short HEAD | sed 's/_.*//')
DESCRIPTION=$(git config branch."$NAME".description)
echo '['"$NAME"'] '$(cat "$1") > "$1"
if [ -n "$DESCRIPTION" ]
then
echo "" >> "$1"
echo $DESCRIPTION >> "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment