-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
~~Link commits in changelog~~ add plugin_path
option to enable loading local plugins
#396
Comments
Hello! This can be achieved using a custom hook. In the example you can see the commit author is being added to each commit, the same can be done for commits: def changelog_message_builder_hook(self, parsed_message: dict, commit: git.GitCommit) -> dict:
rev = commit.rev
m = parsed_message["message"]
parsed_message["message"] = f"{m} {rev} [{commit.rev}](github.com/project/{commit.rev})"
return parsed_message I don't think it makes sense to add links, because if we add github link any other git server (gitlab, bitbucket, etc) would have to have something similar. |
Thanks for the response! Although I think I'm a bit confused how I would add the above function you mentioned to a python configuration file alongside my project. The docs seem to imply I need an entirely separate package/github repo? That seems a bit excessive for a small project-specific configuration change. |
Yes, I think that's the only way as of now. |
As of now the changelog provides some flexibility. I think the design could be improved, but we don't have the capacity at the moment, sorry for that. |
Could adding a config setting pointing to a python file work? The following code is a snippet that can be used to import a module from a given plugin_spec = importlib.util.spec_from_file_location(plugin_path.stem, plugin_path)
if plugin_spec:
plugin_module = importlib.util.module_from_spec(plugin_spec)
plugin_spec.loader.exec_module(plugin_module) source: https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly Maybe then |
Does that mean we'll need to add a This is how we load |
Yes, that's correct. |
Then I think this issue also relates to #264 (comment). We'll need to make cz configurable first. It's on our plan but we're quite busy these days. Not sure when could we support this feature |
I think I'm a bit confused. I'm talking about having a configuration option in your |
After a second thought, I was wrong about the idea. Yep, I think we could add this option. @woile What do you think? |
@Lee-W could you point me towards the relevant code/steps needed to add a new configuration option? If you guys are keen on adding this as a feature, that is. |
commitizen/config/init.py is the file that we use to manage the configuration. But I think we might not need to change it, unless the configuration is complicated. commitizen/cz/init.py is where we load these cz rules. I think this one might be more relevant. |
Example on how to add a custom Python module: #395 (comment). |
plugin_path
option to enable loading local plugins
Description
Add the ability to link a changelog message to the original commit. This would greatly increase the ability to provide context around changes.
Possible Solution
Ability to add a changelog option, so when generating a changelog, it would just add links in the generated markdown for the associated commit message.After #396 (comment), we decide adding a
plugin_path
might be a good solution for it.The text was updated successfully, but these errors were encountered: