Last active
April 15, 2016 14:40
-
-
Save zenchild/1b1a82f1184ffc8b21ad to your computer and use it in GitHub Desktop.
A prepare-commit-msg for Pivotal Tracker
This file contains hidden or 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
#!/usr/bin/env bash | |
# This assumes that your branch is formatted like so: | |
# bug/<ticket_id>_<whatever here> | |
# feature/<ticket_id>_<whatever here> | |
edit_commit_message() { | |
local story_id="[#$1]" | |
sed -i "1i ${story_id}" "${msg_file}" | |
} | |
get_story() { | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$branch" =~ ^(bug|feature)\/([0-9]+)_ ]] | |
then | |
edit_commit_message ${BASH_REMATCH[2]} | |
fi | |
} | |
msg_file="$1" | |
get_story |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment