Skip to content

Commit a12c71c

Browse files
authored
Merge pull request #205 from sysprog21/refine-hooks
Refine hooks
2 parents c3579a8 + d043c41 commit a12c71c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

scripts/check-repo.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ if ! command -v git &>/dev/null; then
2020
throw "git not installed."
2121
fi
2222

23+
# Retrieve git email.
24+
GIT_EMAIL=$(git config user.email)
25+
26+
# Check if email is set.
27+
if [ -z "$GIT_EMAIL" ]; then
28+
throw "Git email is not set."
29+
fi
30+
31+
# Validate email using a regex.
32+
# This regex matches a basic email pattern.
33+
if ! [[ "$GIT_EMAIL" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]]; then
34+
throw "Git email '$GIT_EMAIL' is not valid."
35+
fi
36+
2337
# 1. Sleep for a random number of milliseconds
2438
# The time interval is important to reduce unintended network traffic.
2539
((CURRENT_STEP++))

scripts/commit-msg.hook

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ done
300300
add_warning 1 "Commit subject should use imperative mood"
301301
fi
302302

303+
# 7d. Alert if the commit subject uses the pattern "Implement of ..."
304+
if [[ "${COMMIT_SUBJECT_TO_PROCESS}" =~ ^(Implement|Realize|Update|Finish|Code)[[:space:]]+of[[:space:]]+ ]]; then
305+
add_warning 1 "Avoid using 'of' immediately after the verb"
306+
fi
307+
303308
# 8. Use the body to explain what and why vs. how
304309
# ------------------------------------------------------------------------------
305310

0 commit comments

Comments
 (0)