Skip to content

Instantly share code, notes, and snippets.

@allartk
allartk / commit-msg
Last active October 7, 2024 09:15 — forked from mathiasschopmans/commit-msg
Git commit hook using bash to validate the commit message against conventional commits
#!/usr/bin/env bash
# Credits: https://gist.github.com/mathiasschopmans/70e8d466c620d950f2ca2cea08c4e279#file-how-to-setup-git-commit-hook-for-conventional-commits-using-bash-md
# Get the commit message
commit_msg=$(cat "$1")
# Define a regex pattern to match the conventional commit message format
pattern='^((Merge|Revert) .*$|(api|break|new|feat|fix|docs|refactor|ci|chore|perf|style|test)(: |\(.{1,}\):).*)'