diff --git a/conventional-pre-commit.sh b/conventional-pre-commit.sh index 7deeb11..78f834f 100755 --- a/conventional-pre-commit.sh +++ b/conventional-pre-commit.sh @@ -25,7 +25,7 @@ r_scope="(\([[:alnum:] \/-]+\))?" # optional breaking change indicator and colon delimiter r_delim='!?:' # subject line, body, footer -r_subject=" [[:alnum:]].+" +r_subject=" [[:print:]].+" # the full regex pattern pattern="^$r_types$r_scope$r_delim$r_subject$" diff --git a/tests.sh b/tests.sh index 7c12959..75220e3 100755 --- a/tests.sh +++ b/tests.sh @@ -27,7 +27,7 @@ teardown () { rm -rf "$test_dir" } -# test a failure +echo "test a failure" setup @@ -39,7 +39,9 @@ echo "$fail" | grep -Eq "Your commit message does not follow Conventional Commit (( result += "$?" )) -# test a success +echo "$result" + +echo "test a success" setup @@ -51,4 +53,64 @@ echo "$pass" | grep -Eq "\[main \(root-commit\) [[:alnum:]]{7}\] test: conventio (( result += "$?" )) +echo "$result" + +echo "test printable characters/marks in subject" + +echo "test escaped double quote \"" + +setup + +pass="$(git commit -m 'test: conventional-pre-commit "')" + +teardown + +echo "$pass" | grep -Eq "\[main \(root-commit\) [[:alnum:]]{7}\] test: conventional-pre-commit \"" + +(( result += "$?" )) + +echo "$result" + +echo "test backtick \`" + +setup + +pass="$(git commit -m 'test: conventional-pre-commit `')" + +teardown + +echo "$pass" | grep -Eq "\[main \(root-commit\) [[:alnum:]]{7}\] test: conventional-pre-commit \`" + +(( result += "$?" )) + +echo "$result" + +echo "test hash/number sign #" + +setup + +pass="$(git commit -m 'test: conventional-pre-commit #')" + +teardown + +echo "$pass" | grep -Eq "\[main \(root-commit\) [[:alnum:]]{7}\] test: conventional-pre-commit #" + +(( result += "$?" )) + +echo "$result" + +echo "test ampersand &" + +setup + +pass="$(git commit -m 'test: conventional-pre-commit &')" + +teardown + +echo "$pass" | grep -Eq "\[main \(root-commit\) [[:alnum:]]{7}\] test: conventional-pre-commit &" + +(( result += "$?" )) + +echo "$result" + exit "$result"