Skip to content

--no-raise is not possible with --debug #1294

Open
@diefans

Description

@diefans

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions