Skip to content

Commit 038e0c7

Browse files
committed
refactor(error_codes): move all the error_codes to a module
1 parent 24909fd commit 038e0c7

File tree

6 files changed

+40
-22
lines changed

6 files changed

+40
-22
lines changed

commitizen/commands/bump.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
from commitizen import bump, factory, git, out
77
from commitizen.config import BaseConfig
8-
9-
NO_COMMITS_FOUND = 3
10-
NO_VERSION_SPECIFIED = 4
11-
NO_PATTERN_MAP = 7
12-
COMMIT_FAILED = 8
13-
TAG_FAILED = 9
8+
from commitizen.error_codes import (
9+
NO_COMMITS_FOUND,
10+
NO_VERSION_SPECIFIED,
11+
NO_PATTERN_MAP,
12+
COMMIT_FAILED,
13+
TAG_FAILED,
14+
)
1415

1516

1617
class Bump:

commitizen/commands/check.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
from commitizen import factory, out
55
from commitizen.config import BaseConfig
6-
7-
8-
NO_COMMIT_MSG = 3
9-
INVALID_COMMIT_MSG = 5
6+
from commitizen.error_codes import NO_COMMIT_MSG, INVALID_COMMIT_MSG
107

118

129
class Check:

commitizen/commands/commit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
from commitizen import factory, git, out
88
from commitizen.cz.exceptions import CzException
99
from commitizen.config import BaseConfig
10-
11-
12-
NO_ANSWERS = 5
13-
COMMIT_ERROR = 6
14-
NO_COMMIT_BACKUP = 7
15-
NOTHING_TO_COMMIT = 8
16-
CUSTOM_ERROR = 9
10+
from commitizen.error_codes import (
11+
NO_ANSWERS,
12+
COMMIT_ERROR,
13+
NO_COMMIT_BACKUP,
14+
NOTHING_TO_COMMIT,
15+
CUSTOM_ERROR,
16+
)
1717

1818

1919
class Commit:

commitizen/config/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
from typing import Optional
44

55
from commitizen import defaults, git, out
6+
from commitizen.error_codes import NOT_A_GIT_PROJECT
67
from .base_config import BaseConfig
78
from .toml_config import TomlConfig
89
from .ini_config import IniConfig
910

1011

11-
NOT_A_GIT_PROJECT = 10
12-
13-
1412
def load_global_conf() -> Optional[IniConfig]:
1513
home = Path.home()
1614
global_cfg = home / Path(".cz")

commitizen/error_codes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Commitizen factory
2+
NO_COMMITIZEN_FOUND = 1
3+
4+
# Config
5+
NOT_A_GIT_PROJECT = 2
6+
7+
# Bump
8+
NO_COMMITS_FOUND = 3
9+
NO_VERSION_SPECIFIED = 4
10+
NO_PATTERN_MAP = 5
11+
COMMIT_FAILED = 6
12+
TAG_FAILED = 7
13+
14+
# Commit
15+
NO_ANSWERS = 8
16+
COMMIT_ERROR = 9
17+
NO_COMMIT_BACKUP = 10
18+
NOTHING_TO_COMMIT = 11
19+
CUSTOM_ERROR = 12
20+
21+
# Check
22+
NO_COMMIT_MSG = 13
23+
INVALID_COMMIT_MSG = 14

commitizen/factory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from commitizen import BaseCommitizen, out
22
from commitizen.cz import registry
33
from commitizen.config import BaseConfig
4-
5-
NO_COMMITIZEN_FOUND = 2
4+
from commitizen.error_codes import NO_COMMITIZEN_FOUND
65

76

87
def commiter_factory(config: BaseConfig) -> BaseCommitizen:

0 commit comments

Comments
 (0)