Skip to content

Instantly share code, notes, and snippets.

@AesSedai101
Last active April 23, 2022 05:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AesSedai101/8c6ec454095a35129275794d8f24b829 to your computer and use it in GitHub Desktop.
A git hook to pre-populate a commit message with the ticket number in the branch
#!/bin/sh
MSG_FILE=$1
#Assumes branch names in the format type/ticket-number-description-of-ticket
TICKETNO=`git on | cut -d'/' -f 2 | cut -d'-' -f '-2'`
MSG=`cat $MSG_FILE`
TITLE=`head -n 1 $MSG_FILE`
if [[ $TITLE = *"$TICKETNO"* ]]; then
echo "$MSG" > $MSG_FILE
else
echo "[$TICKETNO]" > $MSG_FILE
echo "" >> $MSG_FILE
echo "$TICKETNO #comment " >> $MSG_FILE
echo "$TICKETNO #time " >> $MSG_FILE
echo "$TICKETNO #status " >> $MSG_FILE
echo "" >> $MSG_FILE
echo "$MSG" >> $MSG_FILE
fi
Copy link

ghost commented Apr 23, 2022

گزارش هرزه نامه

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