fix(changelog): support custom Jinja extensions in release notes templates#1405
Open
bilelomrani1 wants to merge 2 commits intopython-semantic-release:masterfrom
Open
Conversation
Author
|
Just a note: this is a small fix to support custom Jinja extensions in release notes templates. It's self-contained and shouldn't conflict with the v11 refactoring work. See #1407 for the broader context on my use case. Happy to address any feedback whenever you have time to review. |
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.
Purpose
Closes #1402
Custom Jinja extensions configured via
[tool.semantic_release.changelog.environment]were only available in changelog templates, but not in release notes templates.This PR applies the same
changelog.environmentconfiguration when rendering custom release notes templates.Rationale
The
generate_release_notes()function was creating a separate, non-configurable Jinja environment that ignored user settings. This was inconsistent with howwrite_changelog_files()handles custom templates.The fix follows the same pattern used for changelog templates:
template_environmentHow did you test?
test_release_notes_uses_custom_jinja_extension: Verifies custom Jinja extensions with filters are available in release notes templates. All existing release notes tests continue to pass.How to Verify
Configure a custom Jinja extension in
pyproject.toml:Create a custom
.release_notes.md.j2template using a filter from the extension:{{ "text" | my_custom_filter }}Run
semantic-release changelog --post-to-release-tag <tag>orsemantic-release versionVerify the release notes render correctly with the custom filter applied
PR Completion Checklist
Reviewed & followed the Contributor Guidelines
Changes Implemented & Validation pipeline succeeds
Commits follow the Conventional Commits standard
and are separated into the proper commit type and scope (recommended order: test, build, feat/fix, docs)
Appropriate Unit tests added/updated
Appropriate End-to-End tests added/updated
Appropriate Documentation added/updated and syntax validated for sphinx build (see Contributor Guidelines)