Skip to content

Instantly share code, notes, and snippets.

@serhalp
Last active March 26, 2018 19:20
Show Gist options
  • Save serhalp/4426b317cbe39b456c12 to your computer and use it in GitHub Desktop.
Save serhalp/4426b317cbe39b456c12 to your computer and use it in GitHub Desktop.
Pre-populate Git commit message with current branch's Pivotal Tracker story ID
#!/bin/sh
TMP=`git rev-parse --abbrev-ref HEAD | grep -o '[-_]\d\+$'`
STORY_ID=${TMP:1}
if [[ ! -z $STORY_ID ]]
then
ORIG_MSG_FILE="$1"
ORIG_MSG=`cat $1`
(echo "[#$STORY_ID]") > "$ORIG_MSG_FILE"
(echo "$ORIG_MSG") >> "$ORIG_MSG_FILE"
fi
@bogado
Copy link

bogado commented Mar 26, 2018

task="$CURRENT_TASK"
url="$CURRENT_TASK_URL"

if [[ "$task" != "" && ( "$2" == "" || "$2" == "template" ) ]]; then
    printf "%s:\n\nissue: %s\n\n%s" "${task}" "${url}" "$(cat - "$1")" > "$1"
fi

That is my version

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