Skip to content

Instantly share code, notes, and snippets.

View jmcazaux's full-sized avatar

Jean-Michel Cazaux jmcazaux

  • Montpellier, France
View GitHub Profile
@jmcazaux
jmcazaux / commit-msg
Last active August 27, 2021 10:09
Git commit-msg hook to append issue number to commit message
#!/bin/bash
# This hook both checks that the name of the branch matches a given convention
# and extracts the issue number from the branch name to add it to the commit message.
# If it is a multiline commit message the reference to the issue is added as a new line.
# In the case of a single line commit message, the reference is added at the end of the message.
BRANCH_NAME_REGEX="^(ci|docs|feature|fix|hotfix|perf|refactor|test)\/.*$"
ISSUE_NUMBER_REGEX="^.*\#([0-9]+)"