Skip to content

Commit

Permalink
Merge pull request #1441 from digitalgreenorg/feat/git-hooks
Browse files Browse the repository at this point in the history
chore(DEV-106): added git hooks and setup.sh script.
  • Loading branch information
sohitkumar authored Oct 7, 2024
2 parents f3c233d + e708043 commit 48a3b93
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Retrieve the commit message from the file specified as the first argument
commit_msg=$(cat "$1")
echo "Commit message: '$commit_msg'"

# Define a regular expression for the commit message format
commit_regex="^(feat|fix|chore|refactor|docs|test|style|ci|perf|build)\([A-Z]+-[0-9]+\): .+"

# Check if the commit message matches the required format
if [[ ! "$commit_msg" =~ $commit_regex ]]; then
echo "Error: Invalid commit message format."
echo "Your commit message must follow the format: TYPE(PROJECT-123): description."
echo "Valid types: feat, fix, chore, refactor, docs, test, style, ci, perf, build"
echo "Example: feat(PROJECT-123): add authentication module"
exit 1
fi

# If the commit message matches, allow the commit
exit 0
6 changes: 6 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Set up the custom Git hooks directory
git config core.hooksPath ./hooks

echo "Git hooks directory set to ./hooks"

0 comments on commit 48a3b93

Please sign in to comment.