Skip to content

Commit

Permalink
chore: add scripts to help setup recommended hooks
Browse files Browse the repository at this point in the history
Provide script for users to add a git hook to
ensure that commit message match preferred format
  • Loading branch information
c-git committed Feb 2, 2024
1 parent 20adebd commit 3212712
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

regex="^(feat|fix|build|chore|ci|docs|style|refactor|perf|test)(\[.+\])?: .+"

grep -E "$regex" "$1"
if [ $? != 0 ]
then
echo "[error] Commit message doesn't appear to in the conventional commit format"
echo "[info] expecting \"<type>[optional scope]: <description>\""
echo "[info] see https://www.conventionalcommits.org/en/v1.0.0/#summary for more info"
echo "[debug] using regex: \"$regex\""
echo "[debug] on commit message:"
cat "$1"
exit 1
fi
3 changes: 3 additions & 0 deletions scripts/hooks_setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@REM Expected to be run from the scripts folder

copy commit-msg ..\.git\hooks\
5 changes: 5 additions & 0 deletions scripts/hooks_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Expected to be run from the scripts folder

cp commit-msg ../.git/hooks/

0 comments on commit 3212712

Please sign in to comment.