Repository: commitizen-tools/commitizen

Issue:
cz check does not detect incorrectly formatted commit message
## Description

Looks like cz does not detect properly incorrect commit messages, it only parses first line?

## Steps to reproduce
1. create file named BAD_MSG with the following content:
```text
ci: check commit message on merge
testing with more complex commit mes

age with error
```
as you can see there is no empty line between first and second line.

2. run `cz check --commit-msg-file BAD_MSG`

## Current behavior
```
Commit validation: successful!
```

## Desired behavior
```
commit validation: failed!
please enter a commit message in the commitizen format.
commit "": "CI_COMMIT_MESSAGE"
pattern: (build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\(\S+\))?!?:(\s.*)
```

## Environment

cz version -r
```
Commitizen Version: 2.20.0
Python Version: 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0]
Operating System: Linux
```


Comments:

Patch:
diff --git a/commitizen/commands/check.py b/commitizen/commands/check.py
index fb79e805..eed3ffbb 100644
--- a/commitizen/commands/check.py
+++ b/commitizen/commands/check.py
@@ -82,20 +82,18 @@ class Check:
         out.success("Commit validation: successful!")
 
     def _get_commits(self):
+        msg = None
         # Get commit message from file (--commit-msg-file)
         if self.commit_msg_file is not None:
             # Enter this branch if commit_msg_file is "".
             with open(self.commit_msg_file, "r", encoding="utf-8") as commit_file:
                 msg = commit_file.read()
-            msg = self._filter_comments(msg)
-            msg = msg.lstrip("\n")
-            commit_title = msg.split("\n")[0]
-            commit_body = "\n".join(msg.split("\n")[1:])
-            return [git.GitCommit(rev="", title=commit_title, body=commit_body)]
+        # Get commit message from command line (--message)
         elif self.commit_msg is not None:
-            # Enter this branch if commit_msg is "".
-            self.commit_msg = self._filter_comments(self.commit_msg)
-            return [git.GitCommit(rev="", title="", body=self.commit_msg)]
+            msg = self.commit_msg
+        if msg is not None:
+            msg = self._filter_comments(msg)
+            return [git.GitCommit(rev="", title="", body=msg)]
 
         # Get commit messages from git log (--rev-range)
         return git.get_commits(end=self.rev_range)
diff --git a/commitizen/cz/conventional_commits/conventional_commits.py b/commitizen/cz/conventional_commits/conventional_commits.py
index 285f2c14..7989a171 100644
--- a/commitizen/cz/conventional_commits/conventional_commits.py
+++ b/commitizen/cz/conventional_commits/conventional_commits.py
@@ -191,8 +191,11 @@ class ConventionalCommitsCz(BaseCommitizen):
 
     def schema_pattern(self) -> str:
         PATTERN = (
-            r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)"
-            r"(\(\S+\))?!?:(\s.*)"
+            r"(?s)"  # To explictly make . match new line
+            r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)"  # type
+            r"(\(\S+\))?!?:"  # scope
+            r"( [^\n\r]+)"  # subject
+            r"((\n\n.*)|(\s*))?$"
         )
         return PATTERN
 


Test patch:
diff --git a/tests/commands/test_check_command.py b/tests/commands/test_check_command.py
index e5f62d0a..6fbbf322 100644
--- a/tests/commands/test_check_command.py
+++ b/tests/commands/test_check_command.py
@@ -17,20 +17,20 @@ COMMIT_LOG = [
     "refactor(git): remove unnecessary dot between git range",
     "bump: version 1.16.3 → 1.16.4",
     (
-        "Merge pull request #139 from Lee-W/fix-init-clean-config-file\n"
+        "Merge pull request #139 from Lee-W/fix-init-clean-config-file\n\n"
         "Fix init clean config file"
     ),
     "ci(pyproject.toml): add configuration for coverage",
-    "fix(commands/init): fix clean up file when initialize commitizen config\n#138",
+    "fix(commands/init): fix clean up file when initialize commitizen config\n\n#138",
     "refactor(defaults): split config files into long term support and deprecated ones",
     "bump: version 1.16.2 → 1.16.3",
     (
-        "Merge pull request #136 from Lee-W/remove-redundant-readme\n"
+        "Merge pull request #136 from Lee-W/remove-redundant-readme\n\n"
         "Remove redundant readme"
     ),
     "fix: replace README.rst with docs/README.md in config files",
     (
-        "refactor(docs): remove README.rst and use docs/README.md\n"
+        "refactor(docs): remove README.rst and use docs/README.md\n\n"
         "By removing README.rst, we no longer need to maintain "
         "two document with almost the same content\n"
         "Github can read docs/README.md as README for the project."
@@ -38,10 +38,10 @@ COMMIT_LOG = [
     "docs(check): pin pre-commit to v1.16.2",
     "docs(check): fix pre-commit setup",
     "bump: version 1.16.1 → 1.16.2",
-    "Merge pull request #135 from Lee-W/fix-pre-commit-hook\nFix pre commit hook",
+    "Merge pull request #135 from Lee-W/fix-pre-commit-hook\n\nFix pre commit hook",
     "docs(check): enforce cz check only whem committing",
     (
-        'Revert "fix(pre-commit): set pre-commit check stage to commit-msg"\n'
+        'Revert "fix(pre-commit): set pre-commit check stage to commit-msg"\n\n'
         "This reverts commit afc70133e4a81344928561fbf3bb20738dfc8a0b."
     ),
     "feat!: add user stuff",
@@ -129,6 +129,11 @@ def test_check_conventional_commit_succeeds(mocker, capsys):
     (
         "feat!(lang): removed polish language",
         "no conventional commit",
+        (
+            "ci: check commit message on merge\n"
+            "testing with more complex commit mes\n\n"
+            "age with error"
+        ),
     ),
 )
 def test_check_no_conventional_commit(commit_msg, config, mocker, tmpdir):