Skip to content

Instantly share code, notes, and snippets.

@iGEL
Last active December 22, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iGEL/6509561 to your computer and use it in GitHub Desktop.
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
#!/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
@iGEL
Copy link
Author

iGEL commented Sep 10, 2013

Idea from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment