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(config_files): add suport for "cz.toml" config file #1130

Merged
merged 2 commits into from
May 22, 2024

Conversation

marcosdotme
Copy link
Contributor

@marcosdotme marcosdotme commented May 20, 2024

Description

Add support to configure commitizen through cz.toml file.

Checklist

  • Add test cases to all the changes you introduce (see details below!)
  • 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

Be able to initialize and configure commitizen through cz.toml

Screenshots

Test the new config file
  1. Rename the pyproject.toml to whatever
  2. Run cz init and you will see the new possible config file

image

Successfully created the cz.toml:

image

About this feature be already covered by current tests
Since its just an new filename, not extension nor format, its already fully covered by tests.

tests/test_conf.py::TestReadCfg already cover the tests on .toml extension:

image

And also pass all other tests:

image

Closes: #1111

@marcosdotme
Copy link
Contributor Author

Related to #1111

Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.54%. Comparing base (120d514) to head (08f6d0c).
Report is 327 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1130      +/-   ##
==========================================
+ Coverage   97.33%   97.54%   +0.20%     
==========================================
  Files          42       55      +13     
  Lines        2104     2486     +382     
==========================================
+ Hits         2048     2425     +377     
- Misses         56       61       +5     
Flag Coverage Δ
unittests 97.54% <ø> (+0.20%) ⬆️

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.

@woile
Copy link
Member

woile commented May 21, 2024

Please add a test:

You can do something similar to:

class TestTomlConfig:
def test_init_empty_config_content(self, tmpdir):
path = tmpdir.mkdir("commitizen").join(".cz.toml")
toml_config = config.TomlConfig(data="", path=path)
toml_config.init_empty_config_content()
with open(path, encoding="utf-8") as toml_file:
assert toml_file.read() == "[tool.commitizen]\n"

@marcosdotme
Copy link
Contributor Author

Please add a test:

You can do something similar to:

class TestTomlConfig:
def test_init_empty_config_content(self, tmpdir):
path = tmpdir.mkdir("commitizen").join(".cz.toml")
toml_config = config.TomlConfig(data="", path=path)
toml_config.init_empty_config_content()
with open(path, encoding="utf-8") as toml_file:
assert toml_file.read() == "[tool.commitizen]\n"

@woile I added test to cz.toml support and extend some other tests about config files. Can you take a look?

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Lee-W Lee-W added pr-status: ready-to-merge almost ready to merge. just keep it for a few days for others to check and removed pr-status: wait-for-review labels May 21, 2024
@Lee-W Lee-W merged commit 912fda8 into commitizen-tools:master May 22, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: ready-to-merge almost ready to merge. just keep it for a few days for others to check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option for "cz.toml" config file
3 participants