@@ -21,6 +21,8 @@ class CheckArgs(TypedDict, total=False):
21
21
message_length_limit : int
22
22
allowed_prefixes : list [str ]
23
23
message : str
24
+ default_range : bool
25
+ verbose : bool
24
26
25
27
26
28
class Check :
@@ -40,6 +42,8 @@ def __init__(self, config: BaseConfig, arguments: CheckArgs, *args: object) -> N
40
42
self .allow_abort = bool (
41
43
arguments .get ("allow_abort" , config .settings ["allow_abort" ])
42
44
)
45
+ self .default_range = bool (arguments .get ("default_range" ))
46
+ self .verbose = bool (arguments .get ("verbose" ))
43
47
self .max_msg_length = arguments .get ("message_length_limit" , 0 )
44
48
45
49
# we need to distinguish between None and [], which is a valid value
@@ -50,25 +54,28 @@ def __init__(self, config: BaseConfig, arguments: CheckArgs, *args: object) -> N
50
54
else config .settings ["allowed_prefixes" ]
51
55
)
52
56
53
- self ._valid_command_argument ()
54
-
55
- self .config : BaseConfig = config
56
- self .encoding = config .settings ["encoding" ]
57
- self .cz = factory .committer_factory (self .config )
58
-
59
- def _valid_command_argument (self ) -> None :
60
57
num_exclusive_args_provided = sum (
61
58
arg is not None
62
- for arg in (self .commit_msg_file , self .commit_msg , self .rev_range )
59
+ for arg in (
60
+ self .commit_msg_file ,
61
+ self .commit_msg ,
62
+ self .rev_range ,
63
+ )
63
64
)
64
- if num_exclusive_args_provided == 0 and not sys .stdin .isatty ():
65
- self .commit_msg = sys .stdin .read ()
66
- elif num_exclusive_args_provided != 1 :
65
+
66
+ if num_exclusive_args_provided > 1 :
67
67
raise InvalidCommandArgumentError (
68
68
"Only one of --rev-range, --message, and --commit-msg-file is permitted by check command! "
69
69
"See 'cz check -h' for more information"
70
70
)
71
71
72
+ if num_exclusive_args_provided == 0 and not sys .stdin .isatty ():
73
+ self .commit_msg = sys .stdin .read ()
74
+
75
+ self .config : BaseConfig = config
76
+ self .encoding = config .settings ["encoding" ]
77
+ self .cz = factory .committer_factory (self .config )
78
+
72
79
def __call__ (self ) -> None :
73
80
"""Validate if commit messages follows the conventional pattern.
74
81
@@ -109,7 +116,10 @@ def _get_commits(self) -> list[git.GitCommit]:
109
116
return [git .GitCommit (rev = "" , title = "" , body = self ._filter_comments (msg ))]
110
117
111
118
# Get commit messages from git log (--rev-range)
112
- return git .get_commits (end = self .rev_range )
119
+ return git .get_commits (
120
+ git .get_default_branch () if self .default_range else None ,
121
+ self .rev_range ,
122
+ )
113
123
114
124
@staticmethod
115
125
def _filter_comments (msg : str ) -> str :
0 commit comments