From dbfa65354d6d1d0b600ec096b0c4d90dbe9c6147 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 5 Dec 2023 11:54:37 +0530 Subject: [PATCH] feat: signed commit added. --- .githooks/commit-msg | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.githooks/commit-msg b/.githooks/commit-msg index 0848397bd..714bbe3b4 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -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|enhancement):.+" -if ! echo "$commit_msg" | grep -Ei "$commit_regex" ; then - echo "Aborting commit. Your commit message does not follow the conventional format." - echo "Example - : - " + +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', or 'refactor'. For example, it should be formatted like this: 'feat: - '" + 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