Skip to content

Instantly share code, notes, and snippets.

View m-br's full-sized avatar

Morgan Brasseur m-br

  • Geneva, Switzerland
View GitHub Profile
@m-br
m-br / prepare-commit-msg
Last active July 28, 2016 10:15 — forked from cgarnier/prepare-commit-msg
Git prepare-commit-msg hook to extract issue number from branch name and append to commit message.
#!/bin/bash
# Adds reference to GitHub issue if available in branch name.
# The issue number should be at the end of the branch name, following
# a hyphen.
# Only proceed if no second parameter is given to the script.
if [ x = x${2} ]; then
branch=$(git symbolic-ref --short HEAD)
if [[ $branch =~ ^([^/]+)(/([A-Z]+\-[0-9]+))? ]]; then