Skip to content

Instantly share code, notes, and snippets.

@zenchild
Last active April 15, 2016 14:40
Show Gist options
  • Save zenchild/1b1a82f1184ffc8b21ad to your computer and use it in GitHub Desktop.
Save zenchild/1b1a82f1184ffc8b21ad to your computer and use it in GitHub Desktop.
A prepare-commit-msg for Pivotal Tracker
#!/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