FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: preserve blank lines with body length limit by schlotter · Pull Request #2080 · commitizen-tools/commitizen · GitHub

fix: preserve blank lines with body length limit - #2080

Open
schlotter wants to merge 1 commit into
commitizen-tools:masterfrom
ZEISS:fix/body-length-limit-do-not-remove-empty-lines
Open

fix: preserve blank lines with body length limit#2080
schlotter wants to merge 1 commit into
commitizen-tools:masterfrom
ZEISS:fix/body-length-limit-do-not-remove-empty-lines

Conversation

schlotter commented Aug 25, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Fix body_length_limit so it preserves intentional blank lines in commit bodies while still wrapping non-empty lines to the configured width.

Checklist

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

  • Yes (please specify the tool below)

Generated-by: GitHub Copilot CLI following the guidelines

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 — not required, just a fix

Documentation Changes

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

Expected Behavior

With body_length_limit enabled, Commitizen should preserve blank lines in the commit body and only wrap long non-empty lines.

Steps to Test This Pull Request

  1. Configure body_length_limit = 80 or run cz commit --body-length-limit 80.

  2. Create a commit message body with a paragraph break, for example:

    First paragraph line
    
    Second paragraph line
    
  3. Confirm the generated commit message still contains the blank separator line.

  4. Run uv run pytest tests/commands/test_commit_command.py -k body_length_limit.

  5. Run uv run ruff check commitizen/commands/commit.py tests/commands/test_commit_command.py.

  6. Run uv run ruff format --check commitizen/commands/commit.py tests/commands/test_commit_command.py.

Additional Context

This fixes a regression where textwrap.wrap("") caused empty body lines to be dropped when body_length_limit was enabled (#2079).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

commitizen-tools#2079
schlotter changed the title Pleasfix: preserve blank lines with body length limit fix: preserve blank lines with body length limit Aug 25, 2026

codecov Bot commented Aug 25, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.26%. Comparing base (d914b4d) to head (8efb89a).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2080      +/-   ##
==========================================
+ Coverage   98.19%   98.26%   +0.07%     
==========================================
  Files          61       61              
  Lines        2829     2829              
==========================================
+ Hits         2778     2780       +2     
+ Misses         51       49       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

schlotter marked this pull request as ready for review August 25, 2026 14:51
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL