|
2 | 2 | import logging
|
3 | 3 | import sys
|
4 | 4 | import warnings
|
| 5 | +from functools import partial |
5 | 6 |
|
6 | 7 | from decli import cli
|
7 | 8 |
|
|
241 | 242 | original_excepthook = sys.excepthook
|
242 | 243 |
|
243 | 244 |
|
244 |
| -def commitizen_excepthook(type, value, tracekback): |
| 245 | +def commitizen_excepthook(type, value, tracekback, debug=False): |
245 | 246 | if isinstance(value, CommitizenException):
|
246 | 247 | if value.message:
|
247 | 248 | value.output_method(value.message)
|
| 249 | + if debug: |
| 250 | + original_excepthook(type, value, tracekback) |
248 | 251 | sys.exit(value.exit_code)
|
249 | 252 | else:
|
250 | 253 | original_excepthook(type, value, tracekback)
|
251 | 254 |
|
252 | 255 |
|
| 256 | +commitizen_debug_excepthook = partial(commitizen_excepthook, debug=True) |
| 257 | + |
253 | 258 | sys.excepthook = commitizen_excepthook
|
254 | 259 |
|
255 | 260 |
|
@@ -284,14 +289,8 @@ def main():
|
284 | 289 | args.func = commands.Version
|
285 | 290 |
|
286 | 291 | if args.debug:
|
287 |
| - warnings.warn( |
288 |
| - ( |
289 |
| - "Debug will be deprecated in next major version. " |
290 |
| - "Please remove it from your scripts" |
291 |
| - ), |
292 |
| - category=DeprecationWarning, |
293 |
| - ) |
294 | 292 | logging.getLogger("commitizen").setLevel(logging.DEBUG)
|
| 293 | + sys.excepthook = commitizen_debug_excepthook |
295 | 294 |
|
296 | 295 | # TODO: This try block can be removed after command is required in 2.0
|
297 | 296 | # Handle the case that argument is given, but no command is provided
|
|
0 commit comments