2
2
from typing import Optional
3
3
4
4
import questionary
5
- from commitizen import bump , git , config , out
5
+ from commitizen import bump , git , config , out , factory
6
6
7
7
NO_COMMITS_FOUND = 3
8
8
NO_VERSION_SPECIFIED = 4
9
+ NO_PATTERN_MAP = 7
9
10
10
11
11
12
class Bump :
@@ -22,6 +23,7 @@ def __init__(self, config: dict, arguments: dict):
22
23
if arguments [key ] is not None
23
24
},
24
25
}
26
+ self .cz = factory .commiter_factory (self .config )
25
27
26
28
def __call__ (self ):
27
29
"""Steps executed to bump."""
@@ -32,6 +34,7 @@ def __call__(self):
32
34
out .error ("Check if current version is specified in config file, like:" )
33
35
out .error ("version = 0.4.3" )
34
36
raise SystemExit (NO_VERSION_SPECIFIED )
37
+
35
38
current_version : str = self .config ["version" ]
36
39
tag_format : str = self .parameters ["tag_format" ]
37
40
current_tag_version : str = bump .create_tag (
@@ -66,7 +69,14 @@ def __call__(self):
66
69
raise SystemExit (NO_COMMITS_FOUND )
67
70
68
71
if increment is None :
69
- increment = bump .find_increment (commits )
72
+ bump_pattern = self .cz .bump_pattern
73
+ bump_map = self .cz .bump_map
74
+ if not bump_map or not bump_pattern :
75
+ out .error (f"'{ self .config ['name' ]} ' rule does not support bump" )
76
+ raise SystemExit (NO_PATTERN_MAP )
77
+ increment = bump .find_increment (
78
+ commits , regex = bump_pattern , increments_map = bump_map
79
+ )
70
80
71
81
# Increment is removed when current and next version
72
82
# are expected to be prereleases.
0 commit comments