-
Notifications
You must be signed in to change notification settings - Fork 236
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: Allow user customization of release notes template #736
feat: Allow user customization of release notes template #736
Conversation
@danth @relekang @bernardcooke53 could I ask for some help with merging this PR? Based on a parallel PR in my fork (bryant-finney#1), I think it's ready to merge now CC @jmgate |
Excited to be able to use this feature when it makes it in 😀 |
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.
This looks really good - I spent a fair bit of time going over all the changes and testing this locally, I think it's really easy to follow, well-commented and well-tested, thanks for all the effort! 🚀
I've left a couple of comments/questions but nothing major
- add an annotation to the `runtime` object for type analysis - tweak some other annotations to resolve errors - tweak file I/O to use `pathlib.Path.write_text()` ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- similar to 17f9d7a, annotate the `RuntimeContext` and update the annotations in some affected locations - update `pyproject.toml` to report test context responsible for line coverage - remove an unnecessary `if` statement in the `version` command ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
it's available as part of the `pytest` public API, so importing it from there is more robust than using a private location ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
for consistency with other tests, use `requests_mock` functionality instead of targeted `unittest.mock` patching ref: python-semantic-release#736 Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
the `TypeAlias` class was introduced in python 3.10 with PEP 613 ref: https://docs.python.org/3/library/typing.html#typing.TypeAlias ref: https://peps.python.org/pep-0613/ ref: python-semantic-release#736 Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- `CHANGELOG.md`: the `trailing-whitespace` and `mixed-line-ending` hooks were failing - `semantic_release.hvcs.util`: `mypy` was failing for Python 3.11: ``` mypy.....................................................................Failed - hook id: mypy - exit code: 1 semantic_release/hvcs/util.py: note: In function "suppress_http_error_for_codes": semantic_release/hvcs/util.py:74:20: error: Item "None" of "Optional[Response]" has no attribute "status_code" [union-attr] if err.response.status_code in codes: ^~~~~~~~~~~~~~~~~~~~~~~~ semantic_release/hvcs/util.py:78:25: error: Item "None" of "Optional[Response]" has no attribute "status_code" [union-attr] err.response.status_code, ^~~~~~~~~~~~~~~~~~~~~~~~ Found 2 errors in 1 file (checked 45 source files) ``` now, executing `pre-commit run --all-files` from recent Python versions succeeds Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
…tes()` ... for consistency with `semantic_release.cli.common.render_default_changelog_file()` Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- add a new fixture to `tests.fixtures.example_project` to write a template named `.release_notes.md.j2` to the `example_project` fixture's `templates` directory - `tests.command_line.test_changelog:test_custom_release_notes_template()` verifies that that a template named `.release_notes.md.j2` is used to render the release notes - the implementation of feature python-semantic-release#660 cannot be complete until this test passes additionally, update the repo configuration in `tests.fixtures.git_repo` to disable gpg commit signatures Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
move the fixtures introduced in acde492 to `tests.command_line.conftest` so that they can be reused by other test modules Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
some of the fixtures from 13a7af6 were doing too much for reuse in other tests; reducing them allows extraction for the second acceptance test Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- add two new fixtures to tests.command_line.conftest for testing the `version` command - tests.command_line.test_version:test_custom_release_notes_template() verifies that that a template named .release_notes.md.j2 is used to render the release notes - the implementation of feature python-semantic-release#660 cannot be complete until this test passes Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
…ject without using the fixture, the repo was not being initialized with example files Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- convert `RuntimeContext.template_dir` from `str` → `Path` - rename `render_default_release_notes` → `render_release_notes` - expect the template to be provided as an argument - a separate helper function is used to read the template file - update the `changelog` and `version` commands accordingly Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- `Repo.working_tree_dir` can be `None` under certain conditions, so initialize `pathlib.Path` with `'.'` if this happens - the `args` and `kwargs` properties were added to `unittest.mock.Mock.call_args` in Python 3.8, so skip the new tests for Python 3.7 - ref: https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.call_args - Python 3.7 reached EOL status on 2023-06-27, so skipping the tests is acceptable - ref: https://devguide.python.org/versions/ Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- add sections to the `changelog_templates` page Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
refactor the test `test_changelog_noop_is_noop()` in `tests/command_line/test_changelog.py` to provide valid tags (formerly, the tag passed with the --post-to-release-tag argument didn't exist) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- add an annotation to the `runtime` object for type analysis - tweak some other annotations to resolve errors - tweak file I/O to use `pathlib.Path.write_text()` ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
98c68cb
to
5071e0f
Compare
ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- similar to 17f9d7a, annotate the `RuntimeContext` and update the annotations in some affected locations - update `pyproject.toml` to report test context responsible for line coverage - remove an unnecessary `if` statement in the `version` command ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
it's available as part of the `pytest` public API, so importing it from there is more robust than using a private location ref: python-semantic-release#736 (comment) Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
for consistency with other tests, use `requests_mock` functionality instead of targeted `unittest.mock` patching ref: python-semantic-release#736 Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
the `TypeAlias` class was introduced in python 3.10 with PEP 613 ref: https://docs.python.org/3/library/typing.html#typing.TypeAlias ref: https://peps.python.org/pep-0613/ ref: python-semantic-release#736 Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- add an annotation to the `runtime` object for type analysis - tweak some other annotations to resolve errors - tweak file I/O to use `pathlib.Path.write_text()` Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
- similar to 17f9d7a, annotate the `RuntimeContext` and update the annotations in some affected locations - update `pyproject.toml` to report test context responsible for line coverage - remove an unnecessary `if` statement in the `version` command Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
it's available as part of the `pytest` public API, so importing it from there is more robust than using a private location Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
for consistency with other tests, use `requests_mock` functionality instead of targeted `unittest.mock` patching Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
incorrectly documented code is so much worse than undocumented code also convert a `Path` instance to a `str` to appease `mypy` Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
the `TypeAlias` class was introduced in python 3.10 with PEP 613 Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
5071e0f
to
d4f731f
Compare
Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
94a1311
into
python-semantic-release:master
Description
Allow end users to override the default
Jinja2
template for rendering release notes.If a file named
.release_notes.md.j2
exists in the configuredtemplate_dir
, it is used to render the release notes of a given VCS release.Implements #660
Checklist
--noop
argument is handled in theversion
andchangelog
commands to display the rendered release notesMisc. Notes
pre-commit
failurespathlib
usage