Skip to content

Instantly share code, notes, and snippets.

@brgmnn
Last active June 3, 2019 23:56
Show Gist options
  • Save brgmnn/bbdcab298ffdfb675f091c73c37dc6de to your computer and use it in GitHub Desktop.
Save brgmnn/bbdcab298ffdfb675f091c73c37dc6de to your computer and use it in GitHub Desktop.
#!/bin/sh
# Project identifier. This will be either the child technical task identifier or for new tickets
# the project code.
PROJECT=PROJ
case "$2" in
merge);;
squash);;
template);;
commit);;
*)
branch=$(git symbolic-ref HEAD)
ticket=$(echo "$branch" | egrep -o "$PROJECT-[0-9]*")
if [ $? -eq 0 ]; then
printf "\n\nTicket: $ticket\nLink: https://example.com/browse/$ticket\n" \
| cat - $1 > "$1.tmp" && mv "$1.tmp" $1
fi;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment