You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scan for providers using metadata.entry_points in init #1258
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
defdiscover_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() forepinmetadata.entry_points(group="commitizen.provider")
}
versioner: dict[str, type[BaseCommitizen]] =discover_providers()
commitizen/commands/init.py - line 236
opts=list(versioner.keys())
# MergeOPTS.update(
{opt: f"{opt}: Get and set version from {opt}"foroptinopts})
Activity