Skip to content

Instantly share code, notes, and snippets.

@u-mulder

u-mulder/commit-msg.sample Secret

Last active Aug 11, 2017
Embed
What would you like to do?
Get hook to modify commit message
#!/bin/bash
# Contents of commit messsage, it is stored in `.git/COMMIT_EDITMSG` file
INPUT_FILE=$(cat $1)
# Pattern 1: replacing pattern `#DIGITS` (e.g `#211`) with link to jira task
rePattern='https:\/\/jira.somedomain.com\/browse\/SF\-'
# Pattern 2: replacing pattern `#DIGITS` (e.g `#211`) with link to redmine task
rePattern='https:\/\/redmine.somedomain.com\/issues\/'
INPUT_FILE=$(sed -re "s/#([0-9]+)/${rePattern}\1/g" <<< "$INPUT_FILE")
echo "$INPUT_FILE" > $1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.