Skip to content

Enable cover cz_conventional_commits via [tool.commitizen.customize] #1270

Open
@AtticusZeller

Description

@AtticusZeller

Description

hey there👋 it's a fantastic cil tools. thanks for your guys contribution!

it's impossible to cover the default options such as commit Patten via toml after checking the docs and raw code,only will work on complicated full customization in toml which is scary.
😭

the following is the version i would like to use:

[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "semver"
version_provider = "pep621"
update_changelog_on_bump = true
major_version_zero = true
changelog_incremental = false

[tool.commitizen.customize]
commit_parser = "^((?P<change_type>feat|fix|refactor|perf|docs|style|refactor|BREAKING CHANGE)(?:\\((?P<scope>[^()\r\n]*)\\)|\\()?(?P<breaking>!)?|\\w+!):\\s(?P<message>.*)?"
changelog_pattern = "^((BREAKING[\\-\\ ]CHANGE|\\w+)(\\(.+\\))?!?):"
change_type_map = {"feat"="Feat","fix"="Fix","refactor"= "Refactor","perf"="Perf","docs"="Docs","style"="Style"}

of course,[tool.commitizen.customize] would be invalid because of [tool.commitizen] name is not cz_customize according to the docs and raw code.

it looks like we coverd cz_conventional_commits version with [tool.commitizen.customize],which is what we need.

so let's replace the name as cz_customize, it will work on cz bump --dry-run,but cz commit -a would failed for no complete definition [tool.commitizen.customize],also docs had given the complete one looks terrified.

Possible Solution

i think we can realize it via making class CustomizeCommitsCz:to inherit from ConventionalCommitsCz directly.

Activity

woile

woile commented on Oct 22, 2024

@woile
Member

Needs more information and examples. I don't understand what have you tried to do

AtticusZeller

AtticusZeller commented on Oct 23, 2024

@AtticusZeller
Author

sorry for lack of enough context.

in short,I found that the changelog did not include total commit records(only fix feat etc)

i wanna simply keep the current configuration and cover the attr that defines which commit should be involved in changelog with toml extra config

given official config and then cover it,but now we can not cover a bit custom config with toml until the complete custom config In toml

hope it will clarify my feature request.😄

changed the title [-]Enable toml cover custom settings[/-] [+]Enable toml cover partial custom settings[/+] on Oct 23, 2024
woile

woile commented on Oct 23, 2024

@woile
Member

But what did you already do? Can you share the toml that didn't work?
This is a very common case and it's documented here:
https://commitizen-tools.github.io/commitizen/customization/#1-customize-in-configuration-file

commit_parser = "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?"
changelog_pattern = "^(feature|bug fix)?(!)?"
change_type_map = {"feature" = "Feat", "bug fix" = "Fix"}
changed the title [-]Enable toml cover partial custom settings[/-] [+] Enable cover cz_conventional_commits via [tool.commitizen.customize][/+] on Oct 23, 2024
AtticusZeller

AtticusZeller commented on Oct 23, 2024

@AtticusZeller
Author

all finished but docs in #1274!

AtticusZeller

AtticusZeller commented on Oct 25, 2024

@AtticusZeller
Author

if you guys find it really different to customize, I recommend git-cliff or git-changelog.

it would help a lot😊

reopened this on Nov 28, 2024
woile

woile commented on Nov 28, 2024

@woile
Member

I think we should continue with this. It makes sense to allow the modification of an existing provider.
Right @Lee-W @noirbizarre ?

woile

woile commented on Nov 28, 2024

@woile
Member

Maybe instead of breaking tool.commitizen.customize we could create a new one: tool.commitizen.rules.
Which would override the existing commitizen definition:

[tool.commitizen.rules]
commit_parser = "^((?P<change_type>feat|fix|refactor|perf|docs|style|refactor|ci|BREAKING CHANGE)(?:\\((?P<scope>[^()\r\n]*)\\)|\\()?(?P<breaking>!)?|\\w+!):\\s(?P<message>.*)?"
changelog_pattern = "^((BREAKING[\\-\\ ]CHANGE|\\w+)(\\(.+\\))?!?):"
change_type_map = {"feat"="Feat","fix"="Fix","refactor"= "Refactor","perf"="Perf","docs"="Docs","style"="Style","ci"="CI"}

Thoughts?

Lee-W

Lee-W commented on Nov 28, 2024

@Lee-W
Member

Yep, I think we should do it. We probably could make the rule a column of tool.commitizen.customize? If not provided, then it'll work as it is now. If provided, it'll inherit from that cz rule. Might need to do some import or class magic for this, but probably worth exploring 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @woile@Lee-W@AtticusZeller

        Issue actions

          Enable cover cz_conventional_commits via [tool.commitizen.customize] · Issue #1270 · commitizen-tools/commitizen