{{ message }}
feat: add cz dump-config command to output effective configuration - #1986
Closed
bearomorphism wants to merge 1 commit into
Closed
feat: add cz dump-config command to output effective configuration#1986bearomorphism wants to merge 1 commit into
bearomorphism wants to merge 1 commit into
Conversation
Closes commitizen-tools#1331 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
❌ 4 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Collaborator
Author
30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds a new
cz dump-configcommand that prints the effective Commitizen configuration (defaults merged with any project overrides) in TOML, YAML, or JSON format. Users can paste the output directly into a configuration file as a starting template and tweak from there — which is exactly the use-case raised in #1331.Why
Users working with monorepos or custom commit conventions (like the reporter in #1331) struggle because overriding a single setting (e.g.
customize.questions) replaces the entire default. There was no way to see the full effective config without reading source code.cz dump-configsolves this by exposing the merged settings.What changed
commitizen/commands/dump_config.pyDumpConfigcommand classcommitizen/commands/__init__.pyDumpConfigcommitizen/cli.pydump-configsubparser with--formatargumenttests/commands/test_dump_config_command.pytests/commands/test_common_command.pydump-configto help-snapshot parametrize listtests/commands/test_common_command/docs/commands/dump_config.mdmkdocs.ymldump-configto navHow it works
DumpConfig.__call__()readsconfig.settings(aSettingsTypedDict containing defaults merged with user config).Nonevalues are filtered out (TOML cannot representnull), then the dict is wrapped in a[tool.commitizen]section and serialised withtomlkit.dumps().Nonevalues preserved asnull) is wrapped intool.commitizenand serialised withyaml.safe_dump().json.dumps(indent=2).All three formats mirror the input structure so the output can be pasted directly into
pyproject.toml,.cz.yaml, or.cz.json.Backward compatibility
Purely additive — new subcommand only. No existing commands, APIs, or config keys changed.
Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
docs/commands/dump_config.mdmkdocs.ymlnavExpected Behavior
cz dump-config[tool.commitizen]with effective settings (nonullvalues)cz dump-config --format yamltool.commitizenwith effective settingscz dump-config --format json{"tool": {"commitizen": {...}}}Steps to Test This Pull Request
Additional Context
Closes #1331.
The maintainer suggested this could be layered on top of
cz init(#1331 comment), but a standalonecz dump-configis cleaner and more composable (pipe to a file, diff against a known config, etc.).