-
Notifications
You must be signed in to change notification settings - Fork 7
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 #1441 from digitalgreenorg/feat/git-hooks
chore(DEV-106): added git hooks and setup.sh script.
- Loading branch information
Showing
2 changed files
with
26 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,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 |
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 @@ | ||
#!/bin/bash | ||
|
||
# Set up the custom Git hooks directory | ||
git config core.hooksPath ./hooks | ||
|
||
echo "Git hooks directory set to ./hooks" |