Automatically Add JIRA Tickets To Your Commits

by | Nov 4, 2020 | 0 comments

jira-tickets-git-hook

Open Windows Search -> File Explorer Options – > View tab -> Hidden files and folders -> Show hidden files, folders and drives.

 Windows 10:

hidden-directories
sample-hooks
prepare-commit-message is the hook name
chmod +x prepare-commit-msg
#!/bin/bash
branches_list() {
    git branch
}
checked_out_branch() {
    sed -e '/^[^*]/d'
}
get_jira_ticket() {
    grep -e 'TICKET_NAME\+-[0-9]\+' -o
}
get_ticket_from_branch_name() {
    branches_list | checked_out_branch | get_jira_ticket
}
MESSAGE="$(cat $1)"
TICKET=`get_ticket_from_branch_name`

if [ "$TICKET" ]
then
echo "[$TICKET] $MESSAGE" > $1
fi
...
get_jira_ticket() {
  grep -e 'TICKET_NAME+-[0-9]+' -o // Change TICKET_NAME
}
...

IF YOU GOT ANY VALUE SHARE 😄