Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 149a5a9

Browse files
Lee-Wwoile
authored andcommitted
fix(cz/exceptions): exception AnswerRequiredException not caught (#89)
* fix(cz/exceptions): Fix AnswerRequiredException not caught inherit CzException * style(all): run ./script/lint
1 parent db1c4bf commit 149a5a9

File tree

8 files changed

+16
-21
lines changed

8 files changed

+16
-21
lines changed

commitizen/cli.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from commitizen import commands, config, out
99

10-
1110
logger = logging.getLogger(__name__)
1211
data = {
1312
"prog": "cz",

commitizen/commands/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from .bump import Bump
2-
from .commit import Commit
32
from .check import Check
3+
from .commit import Commit
44
from .example import Example
55
from .info import Info
66
from .list_cz import ListCz
77
from .schema import Schema
88
from .version import Version
99

10-
__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema",
11-
"Version")
10+
__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema", "Version")

commitizen/commands/check.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
from commitizen import out
55

6-
PATTERN = (r'(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)'
7-
r'(\([\w\-]+\))?:\s.*')
6+
PATTERN = (
7+
r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)"
8+
r"(\([\w\-]+\))?:\s.*"
9+
)
810
NO_COMMIT_MSG = 3
911
INVALID_COMMIT_MSG = 5
1012

@@ -46,7 +48,7 @@ def __call__(self):
4648

4749
def _get_commit_msg(self):
4850
temp_filename: str = self.arguments.get("commit_msg_file")
49-
return open(temp_filename, 'r').read()
51+
return open(temp_filename, "r").read()
5052

5153
def _is_conventional(self, pattern, commit_msg):
5254
return re.match(PATTERN, commit_msg)

commitizen/cz/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import pkgutil
33

44
from commitizen.cz.conventional_commits import ConventionalCommitsCz
5-
from commitizen.cz.jira import JiraSmartCz
65
from commitizen.cz.customize import CustomizeCommitsCz
6+
from commitizen.cz.jira import JiraSmartCz
77

88
registry = {
99
"cz_conventional_commits": ConventionalCommitsCz,

commitizen/cz/exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ class CzException(Exception):
22
...
33

44

5-
class AnswerRequiredError(Exception):
5+
class AnswerRequiredError(CzException):
66
...

tests/test_bump_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import errno
12
import os
23
import shutil
34
import stat
4-
import errno
55
import sys
66
import uuid
77
from pathlib import Path

tests/test_commands.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,11 @@ def test_check_no_conventional_commit(mocker):
179179
with get_temp_dir() as dir:
180180

181181
tempfile = os.path.join(dir, "temp_commit_file")
182-
with open(tempfile, 'w') as f:
182+
with open(tempfile, "w") as f:
183183
f.write("no conventional commit")
184184

185185
check_cmd = commands.Check(
186-
config=config,
187-
arguments={"commit_msg_file": tempfile}
186+
config=config, arguments={"commit_msg_file": tempfile}
188187
)
189188
check_cmd()
190189
error_mock.assert_called_once()
@@ -195,12 +194,11 @@ def test_check_conventional_commit(mocker):
195194
with get_temp_dir() as dir:
196195

197196
tempfile = os.path.join(dir, "temp_commit_file")
198-
with open(tempfile, 'w') as f:
197+
with open(tempfile, "w") as f:
199198
f.write("feat(lang): added polish language")
200199

201200
check_cmd = commands.Check(
202-
config=config,
203-
arguments={"commit_msg_file": tempfile}
201+
config=config, arguments={"commit_msg_file": tempfile}
204202
)
205203

206204
check_cmd()
@@ -209,7 +207,4 @@ def test_check_conventional_commit(mocker):
209207

210208
def test_check_command_when_commit_file_not_found():
211209
with pytest.raises(FileNotFoundError):
212-
commands.Check(
213-
config=config,
214-
arguments={"commit_msg_file": ""}
215-
)()
210+
commands.Check(config=config, arguments={"commit_msg_file": ""})()

tests/test_cz_customize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22
from tomlkit import parse
33

4-
from commitizen.cz.customize import CustomizeCommitsCz
54
from commitizen.config import Config
5+
from commitizen.cz.customize import CustomizeCommitsCz
66

77

88
@pytest.fixture(scope="module")

0 commit comments

Comments
 (0)