-
-
Notifications
You must be signed in to change notification settings - Fork 267
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(template): allow to override the template from cli, configuration and plugins #645
feat(template): allow to override the template from cli, configuration and plugins #645
Conversation
45d3ceb
to
2f63807
Compare
Codecov ReportAttention:
📢 Thoughts on this report? Let us know!. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @noirbizarre for all your amazing contribution! I start to review this one but i've not yet be able to finish it. I'll do so when I have time. Thanks!
c2ea42a
to
83918e5
Compare
I like the PR 👍🏻 , though I see an issue, commitizen is using markdown to detect which was the last commit made, and from there create an incremental changelog, without touching the rest of the changelog. How would we guarantee this with the templates feature? commitizen/commitizen/changelog.py Lines 150 to 156 in de5c39c
One solution would be to add parameter to the config: [tool.commitizen]
version = "0.3.0"
latest_changelog_version = "0.1.0" Now, it still worries me, how would commitizen know where to inject the incremental changelog? If we allow for example templates in sphinx, or any other template system, how would commitizen know where to inject the template? Even with my provided solution using
without a way to know if it's a title, commitizen would match that, and it would parse that version, potentially injecting the changelog there. Does it make sense what I'm saying haha? Could we have some tests with different templates? For example, using AsciiDoc = Changelog
== 0.1.0
=== Bug Fixes
- update dep X to 0.1.0
Thanks! |
We could potentially add a command to |
Oh, I didn't notice the template parsing. That is definitively something I need to handle in this PR. The problem I see with the What about making This should be backward compatible, Plugin providing their template could override to provide the parsing. For the template from CLI or conf, I can allow providing a string pointing to a custom method, something like: [tool.commitizen]
template = "my_template.whatever"
changelog_version_parser = "path.to:my_parser" I like the |
83918e5
to
2f2dae3
Compare
a0e978f
to
190e20e
Compare
Hi @noirbizarre I notice you have some discussion with @woile . Wondering whether this pr is ready for review now? |
2f2dae3
to
7d46a37
Compare
I rebased it on latest |
Got it. Let me focus on #646 first and will get back to this one afterward 💪 |
7d46a37
to
e5074f1
Compare
e5074f1
to
f2c24c1
Compare
c36e406
to
bcd0f6d
Compare
bcd0f6d
to
398a84b
Compare
I updated the PR including:
I'll close all Python 3.8+ syntax update suggestion for easier review (most of them being in #889 or automatically fixed with ruff). |
@noirbizarre I think we're good to merge this one 🎉 but after merging #889, it seems to have some conflicts 😱 Please merge it once you resolve the conflict. Thanks so much for the hard work! this is a really exciting feature! |
…n and plugins Fixes commitizen-tools#132 Fixes commitizen-tools#384 Fixes commitizen-tools#433 Closes commitizen-tools#376 Closes commitizen-tools#640
398a84b
to
002cde3
Compare
@Lee-W I think this was a GitHub-only weirdness because I wasn't able to display conflict in the Web UI, and locally I haven't got any (I just did a rebase on the current So there it is, PR up to date, waiting for CI to pass, and then it should ready 🚀 🎉 |
hmmm.... not sure what's happening. @noirbizarre do you want to force push to retrigger the github actions again? |
…`commitizen.changelog_format` endpoint (Textile, AsciiDoc and RestructuredText)
002cde3
to
e61aceb
Compare
Done 👍🏼 |
This is driving me crazy !!! 😱 EDIT: build succeeded 🎉. The EDIT2: I tried a lighter change: just updated prettier to the latest version in the test, and it seems to be enough. I don't know whether Windows worker was broken or if there is really an issue with pre-commit, prettier or the Windows runner. Anyway, it worked |
fab77f8
to
28e0a5b
Compare
Awesome news 🎉 🎉 🚀 |
Description
This PR provides full template customization by plugins, configuration and command line.
Plugins can now contribute a template (by providing their own jinja
PackageLoader
astemplate_loader
attribute) as well as more template variables with their defaults (using thetemplate_extras
attribute from `BaseCommitizen). It was my initial use case, I was monkey-patching commitizen like thisUsers can now provide their own template (in the format of their choice, like
.rst
in #384, with extras variables too) by:keep_a_changelog.j2
file at the root of their projecttemplate
config to a project root-relative path to their template--template/-t
parameter in bothbump
andchangelog
commandThey also can provide or override some template variables by:
extras
config which is a dict--extra/-e
parameter (can be used as many times as there are variables) in bothbump
andchangelog
This change is backward compatible, fully tested and documented.
Checklist
./scripts/format
and./scripts/test
locally to ensure this change passes linter check and testAdditional context
Fixes #132
Fixes #384
Fixes #433
Closes #376 (I didn't keep the
tree
toreleases
variable renaming as it is a breaking change (I can however submit this as another PR because I think thereleases
naming is more explicit)