Skip to content

Instantly share code, notes, and snippets.

@yoniamir
yoniamir / commit-msg
Last active April 2, 2023 10:35
Set a git hook that appends the Jira ticket name into the commit message
#!/bin/sh
# Get the current branch name
branch_name=$(git symbolic-ref --short HEAD)
# Extract the ticket number from the branch name using a regex
ticket_number=$(echo $branch_name | grep -o -E '[A-Za-z]+-[0-9]+')
# Check if a ticket number was found
if [ -n "$ticket_number" ]; then
# Read the original commit message from the provided file