@@ -29,7 +29,7 @@ class ExitCode(IntEnum):
2929 INVALID_CONFIGURATION = 19
3030 NOT_ALLOWED = 20
3131 NO_INCREMENT = 21
32- UNRECOGNIZED_CHARACTERSET_ENCODING = 22
32+ CHARACTER_SET_DECODE_ERROR = 22
3333 GIT_COMMAND_ERROR = 23
3434 INVALID_MANUAL_VERSION = 24
3535 INIT_FAILED = 25
@@ -72,32 +72,44 @@ def __init__(self, *args: str, **kwargs: Any) -> None:
7272
7373
7474class DryRunExit (ExpectedExit ):
75- pass
75+ """Exit due to passing `--dry-run` option"""
7676
7777
7878class NoneIncrementExit (CommitizenException ):
79+ """The commits found are not eligible to be bumped"""
80+
7981 exit_code = ExitCode .NO_INCREMENT
8082
8183
8284class NoCommitizenFoundException (CommitizenException ):
85+ """Using a cz (e.g., `cz_jira`) that cannot be found in your system"""
86+
8387 exit_code = ExitCode .NO_COMMITIZEN_FOUND
8488
8589
8690class NotAGitProjectError (CommitizenException ):
91+ """Not in a git project"""
92+
8793 exit_code = ExitCode .NOT_A_GIT_PROJECT
8894 message = "fatal: not a git repository (or any of the parent directories): .git"
8995
9096
9197class MissingCzCustomizeConfigError (CommitizenException ):
98+ """Configuration is missing for `cz_customize`"""
99+
92100 exit_code = ExitCode .MISSING_CZ_CUSTOMIZE_CONFIG
93101 message = "fatal: customize is not set in configuration file."
94102
95103
96104class NoCommitsFoundError (CommitizenException ):
105+ """No commits found"""
106+
97107 exit_code = ExitCode .NO_COMMITS_FOUND
98108
99109
100110class NoVersionSpecifiedError (CommitizenException ):
111+ """Version is not specified in configuration file"""
112+
101113 exit_code = ExitCode .NO_VERSION_SPECIFIED
102114 message = (
103115 "[NO_VERSION_SPECIFIED]\n "
@@ -107,111 +119,166 @@ class NoVersionSpecifiedError(CommitizenException):
107119
108120
109121class NoPatternMapError (CommitizenException ):
122+ """bump / changelog pattern or map can not be found in configuration file"""
123+
110124 exit_code = ExitCode .NO_PATTERN_MAP
111125
112126
113127class BumpCommitFailedError (CommitizenException ):
128+ """Commit failed when bumping version"""
129+
114130 exit_code = ExitCode .BUMP_COMMIT_FAILED
115131
116132
117133class BumpTagFailedError (CommitizenException ):
134+ """Tag failed when bumping version"""
135+
118136 exit_code = ExitCode .BUMP_TAG_FAILED
119137
120138
121139class CurrentVersionNotFoundError (CommitizenException ):
140+ """Current version cannot be found in `version_files`"""
141+
122142 exit_code = ExitCode .CURRENT_VERSION_NOT_FOUND
123143
124144
125145class NoAnswersError (CommitizenException ):
146+ """No user response given"""
147+
126148 exit_code = ExitCode .NO_ANSWERS
127149
128150
129151class CommitError (CommitizenException ):
152+ """git commit error"""
153+
130154 exit_code = ExitCode .COMMIT_ERROR
131155
132156
133157class NoCommitBackupError (CommitizenException ):
158+ """Commit backup file is not found"""
159+
134160 exit_code = ExitCode .NO_COMMIT_BACKUP
135161 message = "No commit backup found"
136162
137163
138164class NothingToCommitError (CommitizenException ):
165+ """Nothing in staging to be committed"""
166+
139167 exit_code = ExitCode .NOTHING_TO_COMMIT
140168
141169
142170class CustomError (CommitizenException ):
171+ """`CzException` raised"""
172+
143173 exit_code = ExitCode .CUSTOM_ERROR
144174
145175
146176class InvalidCommitMessageError (CommitizenException ):
177+ """The commit message does not pass `cz check`"""
178+
147179 exit_code = ExitCode .INVALID_COMMIT_MSG
148180
149181
150182class NoRevisionError (CommitizenException ):
183+ """No revision found"""
184+
151185 exit_code = ExitCode .NO_REVISION
152186 message = "No tag found to do an incremental changelog"
153187
154188
155189class NoCommandFoundError (CommitizenException ):
190+ """No command found when running Commitizen cli (e.g., `cz --debug`)"""
191+
156192 exit_code = ExitCode .NO_COMMAND_FOUND
157193 message = "Command is required"
158194
159195
160196class InvalidCommandArgumentError (CommitizenException ):
197+ """The argument provided to the command is invalid (e.g. `cz check -commit-msg-file filename --rev-range master..`)"""
198+
161199 exit_code = ExitCode .INVALID_COMMAND_ARGUMENT
162200
163201
164202class InvalidConfigurationError (CommitizenException ):
203+ """An error was found in the Commitizen Configuration, such as duplicates in `change_type_order`"""
204+
165205 exit_code = ExitCode .INVALID_CONFIGURATION
166206
167207
168208class NotAllowed (CommitizenException ):
209+ """`--incremental` cannot be combined with a `rev_range`"""
210+
169211 exit_code = ExitCode .NOT_ALLOWED
170212
171213
172214class CharacterSetDecodeError (CommitizenException ):
173- exit_code = ExitCode .UNRECOGNIZED_CHARACTERSET_ENCODING
215+ """The character encoding of the command output could not be determined"""
216+
217+ exit_code = ExitCode .CHARACTER_SET_DECODE_ERROR
174218
175219
176220class GitCommandError (CommitizenException ):
221+ """Unexpected failure while calling a git command"""
222+
177223 exit_code = ExitCode .GIT_COMMAND_ERROR
178224
179225
180226class InvalidManualVersion (CommitizenException ):
227+ """Manually provided version is invalid"""
228+
181229 exit_code = ExitCode .INVALID_MANUAL_VERSION
182230
183231
184232class InitFailedError (CommitizenException ):
233+ """Failed to initialize pre-commit"""
234+
185235 exit_code = ExitCode .INIT_FAILED
186236
187237
188238class RunHookError (CommitizenException ):
239+ """An error occurred during a hook execution"""
240+
189241 exit_code = ExitCode .RUN_HOOK_FAILED
190242
191243
192244class VersionProviderUnknown (CommitizenException ):
245+ """Unknown `version_provider`"""
246+
193247 exit_code = ExitCode .VERSION_PROVIDER_UNKNOWN
194248
195249
196250class VersionSchemeUnknown (CommitizenException ):
251+ """Unknown `version_scheme`"""
252+
197253 exit_code = ExitCode .VERSION_SCHEME_UNKNOWN
198254
199255
200256class ChangelogFormatUnknown (CommitizenException ):
257+ """Unknown `changelog_format` or cannot be determined by the file extension"""
258+
201259 exit_code = ExitCode .CHANGELOG_FORMAT_UNKNOWN
202260 message = "Unknown changelog format identifier"
203261
204262
205263class ConfigFileNotFound (CommitizenException ):
264+ """The configuration file is not found"""
265+
206266 exit_code = ExitCode .CONFIG_FILE_NOT_FOUND
207267 message = "Cannot found the config file, please check your file path again."
208268
209269
210270class ConfigFileIsEmpty (CommitizenException ):
271+ """The configuration file is empty"""
272+
211273 exit_code = ExitCode .CONFIG_FILE_IS_EMPTY
212274 message = "Config file is empty, please check your file path again."
213275
214276
215277class CommitMessageLengthExceededError (CommitizenException ):
278+ """The commit message length exceeds the given limit."""
279+
216280 exit_code = ExitCode .COMMIT_MESSAGE_LENGTH_LIMIT_EXCEEDED
217281 message = "Length of commit message exceeds the given limit."
282+
283+
284+ # When adding / updating a new exit code, please update the documentation of the exit codes in docs/exit_codes.md
0 commit comments