Skip to content

fix: bump command called changelog command with allow_no_commit=True,…#1868

Open
bearomorphism wants to merge 4 commits intomasterfrom
fix-1866
Open

fix: bump command called changelog command with allow_no_commit=True,…#1868
bearomorphism wants to merge 4 commits intomasterfrom
fix-1866

Conversation

@bearomorphism
Copy link
Copy Markdown
Collaborator

@bearomorphism bearomorphism commented Feb 12, 2026

… but changelog command raised NoCommitsFoundError

Fixes #1866

Description

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run uv run poe doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external)

Expected Behavior

Steps to Test This Pull Request

Additional Context

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.99%. Comparing base (dd972c9) to head (72403ad).
⚠️ Report is 57 commits behind head on master.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

Comment thread commitizen/commands/bump.py Outdated
… but changelog command raised NoCommitsFoundError
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_commit flag to the internal Changelog command arguments and uses it to skip the “No commits found” error.
  • Passes allow_no_commit from the bump command into the changelog command invocation.
  • Adds a regression test covering bumping prereleases with --allow-no-commit while 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.

Comment thread commitizen/commands/changelog.py Outdated
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
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Comment thread commitizen/commands/bump.py
Comment thread tests/commands/test_bump_command.py Outdated
Comment thread tests/commands/test_bump_command.py Outdated
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")
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
tmp_commitizen_project = tmp_commitizen_project_initial(version="1.0.0")
tmp_commitizen_project = tmp_commitizen_project_initial()

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@woile woile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread commitizen/commands/changelog.py Outdated
Comment thread tests/commands/test_bump_command.py Outdated
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
@bearomorphism
Copy link
Copy Markdown
Collaborator Author

[AI-generated comment]\n\nAddressed the latest review feedback in 7d59bf4:\n- clarified internal typing/intent for allow_no_commit in changelog\n- normalized forwarded allow_no_commit to bool in bump\n- simplified the regression test setup\n- added docs for changelog behavior when --allow-no-commit is used with bump-triggered changelog generation\n\nValidated with:\nuv run pytest tests/commands/test_bump_command.py -k "allow_no_commit_issue or allow_no_commit_with_no_commit" -q\n(2 passed)

@bearomorphism
Copy link
Copy Markdown
Collaborator Author

Let me draft this PR... I think I need to fix it manually

@bearomorphism bearomorphism marked this pull request as draft April 15, 2026 15:23
bearomorphism and others added 2 commits April 16, 2026 00:03
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>
@bearomorphism bearomorphism marked this pull request as ready for review April 15, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using --allow-no-commit on bump doesn't work (when updating CHANGELOG)

3 participants