diff --git a/scripts/check-repo.sh b/scripts/check-repo.sh index b6bfed3c5..28d40f995 100755 --- a/scripts/check-repo.sh +++ b/scripts/check-repo.sh @@ -20,6 +20,20 @@ if ! command -v git &>/dev/null; then throw "git not installed." fi +# Retrieve git email. +GIT_EMAIL=$(git config user.email) + +# Check if email is set. +if [ -z "$GIT_EMAIL" ]; then + throw "Git email is not set." +fi + +# Validate email using a regex. +# This regex matches a basic email pattern. +if ! [[ "$GIT_EMAIL" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]]; then + throw "Git email '$GIT_EMAIL' is not valid." +fi + # 1. Sleep for a random number of milliseconds # The time interval is important to reduce unintended network traffic. ((CURRENT_STEP++)) diff --git a/scripts/commit-msg.hook b/scripts/commit-msg.hook index da6be14d3..0f807b2e5 100755 --- a/scripts/commit-msg.hook +++ b/scripts/commit-msg.hook @@ -300,6 +300,11 @@ done add_warning 1 "Commit subject should use imperative mood" fi + # 7d. Alert if the commit subject uses the pattern "Implement of ..." + if [[ "${COMMIT_SUBJECT_TO_PROCESS}" =~ ^(Implement|Realize|Update|Finish|Code)[[:space:]]+of[[:space:]]+ ]]; then + add_warning 1 "Avoid using 'of' immediately after the verb" + fi + # 8. Use the body to explain what and why vs. how # ------------------------------------------------------------------------------