Skip to content

Commit

Permalink
chore: signed commit added. (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeeva Ramachandran <[email protected]>
  • Loading branch information
2 people authored and Pritish Budhiraja committed Dec 5, 2023
1 parent e445e08 commit 1d41660
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ commit_msg=$(cat "$commit_msg_file")
npx prettier --write .
npm run re:format

# Define your commit message convention (e.g., starts with "feature:", "fix:", etc.)
commit_regex="^(Merge branch|feat|fix|chore|docs|style|refactor|test|enhancement):.+"
# Define your commit message convention (e.g., starts with "feat:", "fix:", etc.)
commit_regex="^(Merge branch|(feat|fix|chore|refactor|docs|test|style|enhancement):).+"

if ! echo "$commit_msg" | grep -Ei "$commit_regex" ; then
echo "Aborting commit. Your commit message does not follow the conventional format."
echo "Example - <feat>: <subject> - <description>"

if git log -1 --show-signature &> /dev/null; then
if ! echo "$commit_msg" | grep -Ei "$commit_regex" ; then
echo "Aborting commit. Your commit message does not follow the conventional format."
echo "The commit message should begin with one of the following keywords followed by a colon: 'feat', 'fix', 'chore', 'refactor', 'docs', 'test' or 'style'. For example, it should be formatted like this: 'feat: <subject> - <description>'"
exit 1
fi
else
echo "~~~~**** Error: Commit Signature Missing. ****~~~~"
echo "Please make sure to sign your commits. You can sign your commit by using the '-S' option with 'git commit'."
echo "Example: git commit -S -m 'Your commit message'"
exit 1
fi

Expand Down

0 comments on commit 1d41660

Please sign in to comment.