Last active
December 22, 2015 17:59
-
-
Save iGEL/6509561 to your computer and use it in GitHub Desktop.
Gets the Trello card ID from your branch name and includes it into the commit message
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 | |
# Takes the last token of the branch name (separated with an underscore) | |
# takes adds is into the commit message. | |
# | |
# Note: If you want to about committing from the editor, remove the tag and save the file | |
# | |
# 1) Put this file into .git/hooks/prepare-commit-msg | |
# 2) Make it executable: chmod +x .git/hooks/prepare-commit-message | |
CARD_ID=`git rev-parse --abbrev-ref HEAD | sed 's/^.*_//'` | |
PREV_MSG=`cat "$1"` | |
if [ "$CARD_ID" != "HEAD" ]; then | |
if [[ "$PREV_MSG" != *"[#$CARD_ID]"* ]]; then | |
echo "[#$CARD_ID] $PREV_MSG" > $1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Idea from here.