Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(customize.py/test_cz_customize.py): inherit from ConventionalCom… #1274

Closed

Conversation

AtticusZeller
Copy link

@AtticusZeller AtticusZeller commented Oct 23, 2024

enable cz_customize default behavior follow ConventionalCommitsCz without trivial settings

Description

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

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

[tool.commitizen]
name = "cz_customize"
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|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"}

now [tool.commitizen.customize] will cover the ConventionalCommitsCz settings

Steps to Test This Pull Request

  1. add example [tool.commitizen.customize] into your pyproject.toml
  2. cz commit -a,select docs,cz ch --dry-run,docs item will appear in your CHANGELOG.md

here is my test-repo

dependabot bot and others added 30 commits August 23, 2024 10:18
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.1 to 0.6.2.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.6.1...0.6.2)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mypy](https://github.com/python/mypy) from 1.11.1 to 1.11.2.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](python/mypy@v1.11.1...v1.11.2)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.32 to 9.5.33.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.32...9.5.33)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [rich](https://github.com/Textualize/rich) from 13.7.1 to 13.8.0.
- [Release notes](https://github.com/Textualize/rich/releases)
- [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md)
- [Commits](Textualize/rich@v13.7.1...v13.8.0)

---
updated-dependencies:
- dependency-name: rich
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.2 to 0.6.3.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.6.2...0.6.3)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs](https://github.com/mkdocs/mkdocs) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/mkdocs/mkdocs/releases)
- [Commits](mkdocs/mkdocs@1.6.0...1.6.1)

---
updated-dependencies:
- dependency-name: mkdocs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.33 to 9.5.34.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.33...9.5.34)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.3 to 0.6.4.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.6.3...0.6.4)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [types-python-dateutil](https://github.com/python/typeshed) from 2.9.0.20240821 to 2.9.0.20240906.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-python-dateutil
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.4 to 0.6.5.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.6.4...0.6.5)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.2 to 8.3.3.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@8.3.2...8.3.3)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [rich](https://github.com/Textualize/rich) from 13.8.0 to 13.8.1.
- [Release notes](https://github.com/Textualize/rich/releases)
- [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md)
- [Commits](Textualize/rich@v13.8.0...v13.8.1)

---
updated-dependencies:
- dependency-name: rich
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [types-pyyaml](https://github.com/python/typeshed) from 6.0.12.20240808 to 6.0.12.20240917.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-pyyaml
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [importlib-metadata](https://github.com/python/importlib_metadata) from 8.4.0 to 8.5.0.
- [Release notes](https://github.com/python/importlib_metadata/releases)
- [Changelog](https://github.com/python/importlib_metadata/blob/main/NEWS.rst)
- [Commits](python/importlib_metadata@v8.4.0...v8.5.0)

---
updated-dependencies:
- dependency-name: importlib-metadata
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.34 to 9.5.35.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.34...9.5.35)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.5 to 0.6.7.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.6.5...0.6.7)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.35 to 9.5.36.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.35...9.5.36)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.36 to 9.5.37.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.36...9.5.37)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
When the tag_format does not follow the allowed schemas patterns then changlog generation fails.
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.37 to 9.5.38.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.37...9.5.38)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.7 to 0.6.8.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.6.7...0.6.8)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.38 to 9.5.39.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](squidfunk/mkdocs-material@9.5.38...9.5.39)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [rich](https://github.com/Textualize/rich) from 13.8.1 to 13.9.1.
- [Release notes](https://github.com/Textualize/rich/releases)
- [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md)
- [Commits](Textualize/rich@v13.8.1...v13.9.1)

---
updated-dependencies:
- dependency-name: rich
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 97.72727% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (v4@737c24c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
commitizen/commands/commit.py 90.90% 2 Missing ⚠️
commitizen/cz/customize/customize.py 96.66% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##             v4    #1274   +/-   ##
=====================================
  Coverage      ?   97.62%           
=====================================
  Files         ?       55           
  Lines         ?     2612           
  Branches      ?        0           
=====================================
  Hits          ?     2550           
  Misses        ?       62           
  Partials      ?        0           
Flag Coverage Δ
unittests 97.62% <97.72%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AtticusZeller
Copy link
Author

@woile

@woile
Copy link
Member

woile commented Oct 25, 2024

@Lee-W what are you thoughts on this? I'm not a big user of customize. Would this change break things?

@AtticusZeller
Copy link
Author

it's ridiculous that not allowed custom via toml.
it against Python style 😓😓😓

@woile
Copy link
Member

woile commented Oct 25, 2024

I don't follow. Why is it not allowed? Can't you wait for a maintainer more familiar with customize?

@Lee-W
Copy link
Member

Lee-W commented Oct 26, 2024

Hi there, I'm a bit overwhelmed these days. Will take a look

@Lee-W
Copy link
Member

Lee-W commented Oct 26, 2024

Took a quick look. This is a great one! But this is a breaking change, so we'll include it in v4. Another thought I always have is that we should probably just deprecate cz_customize and make this behavior applicable to all the cz whenever possible.

@AtticusZeller
Copy link
Author

Took a quick look. This is a great one! But this is a breaking change, so we'll include it in v4. Another thought I always have is that we should probably just deprecate cz_customize and make this behavior applicable to all the cz whenever possible.

thank you for review, if you plan to involve this feature, @me anytime 👋

@AtticusZeller AtticusZeller reopened this Oct 26, 2024
@Lee-W
Copy link
Member

Lee-W commented Oct 26, 2024

Took a quick look. This is a great one! But this is a breaking change, so we'll include it in v4. Another thought I always have is that we should probably just deprecate cz_customize and make this behavior applicable to all the cz whenever possible.

thank you for review, if you plan to involve this feature, @me anytime 👋

We could just merge it into v4 after reviewing. But would like to know whether you're interested in designing how to make everything in a cz_ customizable through toml/json and etc. 🙂 If so, we probably could open an issue for that.
Another thing we can do is make this v4 and the ultimate customizing thing to v5.
But yep again, I only have limited bandwidth these days 🥲 (so many PR and issue waiting for me 😭) Will try my best to help!

@Lee-W Lee-W changed the base branch from master to v4 October 26, 2024 04:53
@AtticusZeller
Copy link
Author

But would like to know whether you're interested in designing how to make everything in a cz_ customizable through toml/json and etc.

  1. of course, we love upgrading something and help each other , but be free In happy new year

  2. and I believe that the following changes, reactoring custom from toml,json must be careful

because there is much functions that each one can be treated as individual Project

we should be careful on these parts interactions

inspite of the cz custom function, it's not the one would be complex. bump my version git-cliff etc. are good reference.

thanks.

@AdrianDC
Copy link
Contributor

AdrianDC commented Nov 1, 2024

If the goal is to customize everything through .cz.yaml, modularity would in deed be helpful,
because all elements have to be reimplemented or worked around for the time being.

Completed with the other PRs, this is the configurations I implemented and use over 30-40 projects since August :
https://gitlab.com/RadianDevCore/tools/pre-commit-crocodile/-/blob/develop/.cz.yaml

As I said earlier to Lee, I'd need to take some time (after MRs) to revert it to basic Conventional Commits,
as you'll see I documented in a comments section the variations we apply (mandatory scope, security type, ! breaking changes, wip, ...)

@Lee-W
Copy link
Member

Lee-W commented Nov 2, 2024

But would like to know whether you're interested in designing how to make everything in a cz_ customizable through toml/json and etc.

1. of course, we love upgrading something and help each other , but be free In happy new year

2. and I believe that the following changes, reactoring custom from toml,json must be careful

because there is much functions that each one can be treated as individual Project

we should be careful on these parts interactions

inspite of the cz custom function, it's not the one would be complex. bump my version git-cliff etc. are good reference.

thanks.

Yep, it's indeed something we need to be cautious and would need some time to design it throughfully.

@Lee-W
Copy link
Member

Lee-W commented Nov 2, 2024

If the goal is to customize everything through .cz.yaml, modularity would in deed be helpful, because all elements have to be reimplemented or worked around for the time being.

The original goal of cz_customize. Yes.

As I said earlier to Lee, I'd need to take some time (after MRs) to revert it to basic Conventional Commits, as you'll see I documented in a comments section the variations we apply (mandatory scope, security type, ! breaking changes, wip, ...)

Yep, so what I'm thinking of is deprecating cz_customize and make every cz_ rule customizeable through toml yaml json whenever possible.

@AtticusZeller
Copy link
Author

and by the way, I'm not sure if you'd be interested in trying to refactor using Typer, a modern Python CLI framework. It can greatly simplify existing code and easily implement type validation and common CLI components. The author is the same person who created the FastAPI framework. Here's the repo

@Lee-W
Copy link
Member

Lee-W commented Nov 5, 2024

and by the way, I'm not sure if you'd be interested in trying to refactor using Typer, a modern Python CLI framework. It can greatly simplify existing code and easily implement type validation and common CLI components. The author is the same person who created the FastAPI framework. Here's the repo

Yep, I'm aware of this lib. I guess I'm "ok" with this change if anyone wants to change it. But would like to know if @woile think it's a good idea. 🤔

@AtticusZeller AtticusZeller closed this by deleting the head repository Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants