Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conventional-pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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$"

Expand Down
66 changes: 64 additions & 2 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ teardown () {
rm -rf "$test_dir"
}

# test a failure
echo "test a failure"

setup

Expand All @@ -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

Expand All @@ -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"