This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BRANCH_PATH=$(git symbolic-ref -q HEAD) # Something like refs/heads/my-branch-name | |
BRANCH_NAME=${BRANCH_PATH##*/} # Get text behind the last / of the branch path | |
# Make sure we have an issue number in front before doing anything | |
if [[ $BRANCH_NAME =~ (^[0-9]{4}) ]] ;then | |
ISSUE_NUMBER=${BASH_REMATCH[1]} | |
FIRST_LINE=$(head -n1 $1) | |
# make sure there isn't already a "fixes ISSUE_NUMBER" line in message (ex. if it's an amend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This adds "fixes #0000" to the third line of the commit message automatically | |
# if there is an issue number in front of the branch name. | |
BRANCH_PATH=$(git symbolic-ref -q HEAD) # Something like refs/heads/my-branch-name | |
BRANCH_NAME=${BRANCH_PATH##*/} # Get text behind the last / of the branch path | |
# Make sure we have an issue number in front before doing anything | |
if [[ $BRANCH_NAME =~ (^[0-9]{4}) ]] ;then | |
ISSUE_NUMBER=${BASH_REMATCH[1]} | |
FIRST_LINE=$(head -n1 $1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# adapted from https://dzone.com/articles/why-your-need-git-pre-commit | |
# store this bad-dad as .git/hooks/pre-commit | |
import os | |
import re | |
import subprocess | |
import sys | |
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)') |