Skip to content

Commit

Permalink
fix(hook): 🐛 fix regression that prevented displaying the cog verify …
Browse files Browse the repository at this point in the history
…message

Signed-off-by: Eric Villard <[email protected]>
  • Loading branch information
eviweb committed Jun 24, 2022
1 parent 97f88af commit 28d5507
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/git/hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ MESSAGE="$(cat "${COMMIT_MSG_FILE}")"

[[ "${LEGACY_COMMIT_MESSAGE}" -ne 1 ]] || exit 0

if "$(bin)"/cog verify "${MESSAGE}" |& grep -q "(not committed) - now"; then
echo "${MESSAGE}" | "$(bin)"/insert-icon > "${COMMIT_MSG_FILE}"
result="$("$(bin)"/cog verify "${MESSAGE}" |& cat)"
echo "$result"

else
if echo "${result}" | grep -q "(not committed) - now"; then
echo "${MESSAGE}" | "$(bin)"/insert-icon > "${COMMIT_MSG_FILE}"
else
echo "See https://www.conventionalcommits.org/en/v1.0.0"
exit 1
fi
18 changes: 18 additions & 0 deletions tests/commit-msg-hook-test
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,21 @@ result="$?"
assert_equals "0" "${result}"

unlink "${commitmsgfile}"

####
echo -e "\n> Test display the cog verify success message:"
commitmsgfile="$(new_temp_file "$(cat "$(fixtures_dir)/COMMIT_EDITMSG")")"
result="$("$(hooks_dir)"/commit-msg "${commitmsgfile}" |& grep -o "(not committed) - now")"

assert_equals "(not committed) - now" "${result}"

unlink "${commitmsgfile}"

####
echo -e "\n> Test display the cog verify error message:"
commitmsgfile="$(new_temp_file "$(cat "$(fixtures_dir)/NOT_SEMANTIC_COMMIT_EDITMSG")")"
result="$("$(hooks_dir)"/commit-msg "${commitmsgfile}" |& grep "Caused by:")"

assert_equals "Caused by:" "${result}"

unlink "${commitmsgfile}"

0 comments on commit 28d5507

Please sign in to comment.