Description
Description
Currently, when running the cz init
command, Commitizen scans for plugins using the registry populated by metadata.entry_points(group="commitizen.plugin")
in commitizen/cz/__init__.py
.
However, for providers, while the cz version
command scans and detects third-party providers dynamically, the cz init
command relies on a fixed list of providers. This makes it difficult to discover or configure new providers during the initialization process.
To improve usability, cz should implement dynamic discovery of providers during cz init
, similar to how third-party plugins are handled, allowing for easier integration of new or custom providers.
I have locally implemented the feature and I'd be willing to provide a PR if possible.
Possible Solution
Create a similar registry for providers and populate it using metadata.entry_points(group="commitizen.provider"). Concatenate the results with the hardcoded one in (commitizen/commands/init.py:227)
commitizen/cz/init.py
def discover_providers() -> dict[str, type[VersionProvider]]:
"""Discover commitizen version providers on the path
Returns:
Dict[str, Type[VersionProvider]]: Registry with found version providers
"""
return {
ep.name: ep.load() for ep in metadata.entry_points(group="commitizen.provider")
}
versioner: dict[str, type[BaseCommitizen]] = discover_providers()
commitizen/commands/init.py - line 236
opts = list(versioner.keys())
# Merge
OPTS.update(
{opt: f"{opt}: Get and set version from {opt}" for opt in opts})
Additional context
No response
Additional context
No response