Skip to content

Commit

Permalink
Use perl regex
Browse files Browse the repository at this point in the history
  • Loading branch information
maor-rozenfeld committed Mar 25, 2024
1 parent f5a279e commit 2273717
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[ -z "$ERROR_MESSAGE" ] && echo "Error: ERROR_MESSAGE is null or empty" >&2 && exit 1

# Match regex title with the title
if grep -qE -- "$TITLE_REGEX" <<< "$TITLE"; then
if grep -qP -- "$TITLE_REGEX" <<< "$TITLE"; then
echo "Title matches regex: $TITLE_REGEX"
else
echo "Error: Title does not match regex: $TITLE_REGEX" >&2
Expand Down
21 changes: 17 additions & 4 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

set -e

TITLE="Add something" \
if TITLE="Add something" \
TITLE_REGEX="^Add" \
ERROR_MESSAGE="N/A" \
./lint.sh && echo "Pass"
./lint.sh; then echo "Pass"; else echo "Failed" && exit 1; fi

if TITLE="Add something" \
if ! TITLE="Add something" \
TITLE_REGEX="^[a-z]" \
ERROR_MESSAGE="Must be lower case" \
./lint.sh; then echo "Failed" && exit 1; else echo "Pass"; fi
./lint.sh; then echo "Pass"; else echo "Failed" && exit 1; fi

if TITLE="Fix a thing" \
TITLE_REGEX="^(?!\\S+ing\\s)(?!\\S+ed\\s)" \
ERROR_MESSAGE="Must be lower case" \
./lint.sh; then echo "Pass"; else echo "Failed" && exit 1; fi

if TITLE="Fix a thing" \
TITLE_REGEX="^(?!\\S+ing\\s)(?!\\S+ed\\s)" \
ERROR_MESSAGE="Must be lower case" \
./lint.sh; then echo "Pass"; else echo "Failed" && exit 1; fi


echo All tests passed

0 comments on commit 2273717

Please sign in to comment.