fix: bump command called changelog command with allow_no_commit=True,…#1868
fix: bump command called changelog command with allow_no_commit=True,…#1868bearomorphism wants to merge 4 commits intomasterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1868 +/- ##
=======================================
Coverage 97.98% 97.99%
=======================================
Files 60 60
Lines 2686 2693 +7
=======================================
+ Hits 2632 2639 +7
Misses 54 54 ☔ View full report in Codecov by Sentry. |
83e11ab to
a1d944c
Compare
… but changelog command raised NoCommitsFoundError
a1d944c to
0598e36
Compare
There was a problem hiding this comment.
Pull request overview
Fixes cz bump --allow-no-commit failures when update_changelog_on_bump = true and there are no commits between bumps (Issue #1866), by ensuring changelog generation doesn’t raise NoCommitsFoundError in that scenario.
Changes:
- Adds an
allow_no_commitflag to the internalChangelogcommand arguments and uses it to skip the “No commits found” error. - Passes
allow_no_commitfrom thebumpcommand into thechangelogcommand invocation. - Adds a regression test covering bumping prereleases with
--allow-no-commitwhile updating the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
commitizen/commands/changelog.py |
Accepts/stores allow_no_commit and uses it to suppress NoCommitsFoundError when there are no commits. |
commitizen/commands/bump.py |
Forwards allow_no_commit into changelog generation during bump. |
tests/commands/test_bump_command.py |
Adds a regression test reproducing Issue #1866. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| extras: dict[str, Any] | ||
| export_template: str | ||
| during_version_bump: bool | None | ||
| allow_no_commit: bool # --allow-no-commit is still invalid in the changelog command |
There was a problem hiding this comment.
allow_no_commit is declared as a plain bool here, but BumpArgs.allow_no_commit is bool | None and bump.py forwards that value. To keep typing consistent (and avoid mypy complaints when passing None), consider changing this to bool | None and/or coercing to bool at the call site. Also, the inline comment says the flag is still invalid for the changelog command; if this is intended to be internal-only (used by bump), the comment should be clarified to avoid confusion.
| allow_no_commit: bool # --allow-no-commit is still invalid in the changelog command | |
| allow_no_commit: bool | None # Internal-only when invoked by bump; still not a direct changelog CLI flag. |
| util: UtilFixture, | ||
| ) -> None: | ||
| """Issue #1866: bump command called changelog command with allow_no_commit=True, but changelog command raised NoCommitsFoundError""" | ||
| tmp_commitizen_project = tmp_commitizen_project_initial(version="1.0.0") |
There was a problem hiding this comment.
tmp_commitizen_project_initial(version="1.0.0") sets up [tool.commitizen] version = "1.0.0", but the test immediately overwrites pyproject.toml with a different version/provider setup. To reduce confusion and make the fixture intent clearer, consider dropping the version= override (or aligning it with the version written into the new pyproject.toml).
| tmp_commitizen_project = tmp_commitizen_project_initial(version="1.0.0") | |
| tmp_commitizen_project = tmp_commitizen_project_initial() |
woile
left a comment
There was a problem hiding this comment.
Please also update the documentation explaining the behavior of changelog when allow_no_commit is True and what it does 🙏🏻
Like what is mention in the OP ticket #1866 could be a good idea:
alter the CHANGELOG to indicate there has been a release but nothing has changed
Align internal typing/forwarding for allow_no_commit, simplify the regression test setup, and document how changelog entries are generated during no-commit bumps. Made-with: Cursor
|
[AI-generated comment]\n\nAddressed the latest review feedback in 7d59bf4:\n- clarified internal typing/intent for |
|
Let me draft this PR... I think I need to fix it manually |
Document that allow_no_commit in ChangelogArgs is internal-only for bump-triggered changelog generation. Made-with: Cursor
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… but changelog command raised NoCommitsFoundError
Fixes #1866
Description
Checklist
Was generative AI tooling used to co-author this PR?
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
Steps to Test This Pull Request
Additional Context