Skip to content

Instantly share code, notes, and snippets.

Patrick McHeyser patrickmch

Block or report user

Report or block patrickmch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View commit-msg
#!/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)
View prepare-commit-msg
#!/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)
@patrickmch
patrickmch / pre-commit
Last active Dec 21, 2018
pre-commit hook
View pre-commit
#!/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>.*)')
You can’t perform that action at this time.