-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from rust-practice/conventional-commits-hook
chore: add scripts to help setup recommended hooks
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@echo off | ||
@REM Expected to be run from the scripts folder | ||
|
||
copy commit-msg ..\.git\hooks\ | ||
|
||
if %ERRORLEVEL% NEQ 0 echo [error] The copy seems to have failed. This script expects to be run from inside the scripts folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
# Expected to be run from the scripts folder | ||
|
||
cp commit-msg ../.git/hooks/ | ||
|
||
if [ $? != 0 ] | ||
then | ||
echo "[error] The copy seems to have failed. This script expects to be run from inside the scripts folder" | ||
exit 1 | ||
fi |