commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

changelog generation is not working as expected in case of cz_customize?

Open brunopereira7 opened this issue 4 years ago • 10 comments

Description

Maybe I'm missing something but I'm not able to generate a changelog properly with custom configurations (cz_customize).

Steps to reproduce

cz --debug changelog --dry-run

Current behavior

I've tried different configurations through cz_customize, although the customization related to commits seems ok, the changelog generation doesn't work for me. I'm not able to generate a changelog as I do with the cz_conventional_commits. There is no filtering on the commits, no grouping by change_type as you can see below.

File: .cz.yaml

commitizen:
  name: cz_customize
  customize:
    message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
    example: 'feature: this feature enable customize through config file'
    schema: "<type>: <body>"
    schema_pattern: (build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\(\S+\))?!?:(\s.*)
    changelog_pattern: ^(feat|fix|chore|refactor|perf)(\(.+\))?(!)?
    change_type_order: ["BREAKING CHANGE", "feat", "fix", "refactor", "chore", "perf"]
    info_path: cz_customize_info.txt
    info: This is customized info
    questions:
    - type: list
      name: change_type
      choices:
      - value: feature
        name: 'feature: A new feature.'
      - value: bug fix
        name: 'bug fix: A bug fix.'
      message: Select the type of change you are committing
    - type: input
      name: message
      message: Body.
    - type: confirm
      name: show_message
      message: Do you want to add body message in commit?
cz --debug changelog --dry-run
## Unreleased


- feat(DL-4567): new feature test
- fix(DL-1234): qweqwe

Screenshots

image

Desired behavior

File: .cz.yaml

commitizen:
  name: cz_customize
  customize:
    message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
    example: 'feature: this feature enable customize through config file'
    schema: "<type>: <body>"
    schema_pattern: (build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\(\S+\))?!?:(\s.*)
    changelog_pattern: ^(feat|fix|chore|refactor|perf)(\(.+\))?(!)?
    change_type_order: ["BREAKING CHANGE", "feat", "fix", "refactor", "chore", "perf"]
    info_path: cz_customize_info.txt
    info: This is customized info
    questions:
    - type: list
      name: change_type
      choices:
      - value: feature
        name: 'feature: A new feature.'
      - value: bug fix
        name: 'bug fix: A bug fix.'
      message: Select the type of change you are committing
    - type: input
      name: message
      message: Body.
    - type: confirm
      name: show_message
      message: Do you want to add body message in commit?
cz --debug changelog --dry-run`
## Unreleased

### Feat

- **DL-4567**: new feature test

### Fix

- **DL-1234**: qweqwe

Screenshots image

Environment

Commitizen Version: 2.20.0 Python Version: 3.10.0 (default, Oct 12 2021, 22:37:59) [Clang 13.0.0 (clang-1300.0.29.3)] Operating System: Darwin

brunopereira7 avatar Dec 22 '21 18:12 brunopereira7

Hey bruno, I copied your example, seems to be working well. You see that error because of the --debug flag. Which gives you extra information, but it is not returning an error (you can see the error code doing echo $? and you'll see is still 0).

Let me know if that's correct, otherwise we can continue exploring the issue.

Cheers!

woile avatar Dec 23 '21 07:12 woile

Hey Santiago, thanks for your input.

I switched on the --debug flag to check if I have any extra information that could explain what I'm missing, but maybe I was not clear in explaining the issue (btw, I updated the "Desired Behavior" section).

I want to generate the changelog (as it is generated by default with cz_conventional_commits) using cz_customize definitions. Maybe I'm missing something in my configuration, but after trying different settings with cz_customize, I'm not able to achieve the changelog generation features:

  • Grouping by change_type
  • Have only commits following the conventional commits specification/schema pattern

Thanks once again, and let me know if you need further information.

brunopereira7 avatar Dec 23 '21 10:12 brunopereira7

I think the commit_parser regex is not exposed in the customize

https://github.com/commitizen-tools/commitizen/blob/095f02e6c419b60c90aa84b8cebc9e9eacc8a391/commitizen/defaults.py#L83

and it looks like the customize is using the default from the base

https://github.com/commitizen-tools/commitizen/blob/095f02e6c419b60c90aa84b8cebc9e9eacc8a391/commitizen/cz/base.py#L30

Any thoguhts on this @Lee-W ? Was there a reason for not exposing commit_parser?

woile avatar Dec 23 '21 11:12 woile

Back to the time cz_customize was designed, it was not designed to have any default value. But there might be some default values accidentally added to cz_cutsomize. What's in my mind now is to deprecate cz_customize and make the options in cz_* customizable

Lee-W avatar Dec 24 '21 03:12 Lee-W

Any updates on this topic? I stumbled over this, too. Or do I need to create a custom cz_ plugin?

whoracle avatar Jun 10 '22 11:06 whoracle

We're out of bandwidth to implement this feature these days. PR is welcome 🙂

Lee-W avatar Jul 22 '22 15:07 Lee-W

I think commit_parser is exposed since https://github.com/commitizen-tools/commitizen/pull/442.

Better default handling for cz_customize as suggested by @Lee-W is also discussed here: https://github.com/commitizen-tools/commitizen/issues/535

robertschweizer avatar Mar 29 '23 09:03 robertschweizer

@Lee-W any updates to use cz_customize with default parser ?

shantonio avatar Jun 26 '23 18:06 shantonio

No update at this moment. Would appreciate it if anyone wants to take a look 🙂

Lee-W avatar Jun 27 '23 02:06 Lee-W