Skip to content

Commit

Permalink
Validate email of git configuration
Browse files Browse the repository at this point in the history
This regex matches a basic email pattern.

Change-Id: I7196a97db325c73f3b88462b69edc2ddc7d0fbce
  • Loading branch information
jserv committed Feb 23, 2025
1 parent eec9e7f commit d043c41
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/check-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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++))
Expand Down

0 comments on commit d043c41

Please sign in to comment.