commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

`--no-raise` is not possible with `--debug`

Open diefans opened this issue 1 year ago • 0 comments

Description

The actual code is clearly excluding --no-raise if --debug is set (https://github.com/commitizen-tools/commitizen/blob/master/commitizen/cli.py#L640-L648)

    if args.debug:
        logging.getLogger("commitizen").setLevel(logging.DEBUG)
        sys.excepthook = commitizen_debug_excepthook
    elif args.no_raise:
        no_raise_exit_codes = parse_no_raise(args.no_raise)
        no_raise_debug_excepthook = partial(
            commitizen_excepthook, no_raise=no_raise_exit_codes
        )
        sys.excepthook = no_raise_debug_excepthook

Since sys.excepthook is defined here https://github.com/commitizen-tools/commitizen/blob/master/commitizen/cli.py#L564 we can have possible working solution by iteratively precising the partial e.g.:

    if args.debug:
        logging.getLogger("commitizen").setLevel(logging.DEBUG)
        sys.excepthook = commitizen_debug_excepthook
    if args.no_raise:
        no_raise_exit_codes = parse_no_raise(args.no_raise)
        no_raise_debug_excepthook = partial(
            sys.excepthook, no_raise=no_raise_exit_codes
        )
        sys.excepthook = no_raise_debug_excepthook

Steps to reproduce

cz --debug --no-raise 21 bump --yes --changelog --dry-run

Current behavior

The usage of --debug prevents the usage of --no-raise

Desired behavior

I want to use --debug and --no-raise together.

Screenshots

No response

Environment

cz version
3.31.0

diefans avatar Nov 18 '24 13:11 diefans