Skip to content

fix(conventional_commit): preserve body text matching a footer - #1126

Open
amalsaidov wants to merge 1 commit into
invertase:mainfrom
amalsaidov:fix/conventional-commit-body-footer-substring
Open

amalsaidov wants to merge 1 commit into
invertase:mainfrom
amalsaidov:fix/conventional-commit-body-footer-substring

Conversation

@amalsaidov

Copy link
Copy Markdown

Description

ConventionalCommit.tryParse builds the commit body by stripping each extracted footer out of the message with String.replaceAll:

for (final footer in footers) {
  body = body!.replaceAll(footer, '');
}

replaceAll removes every occurrence of the footer text, not just the trailing footer line. If a body paragraph legitimately contains the same text as a footer, the inline occurrence is silently deleted and the parsed body is corrupted.

Reproduction

fix: resolve timeout

The old Refs #123 approach was wrong and needed a rewrite.

Refs #123
  • Expected body: The old Refs #123 approach was wrong and needed a rewrite.
  • Actual body: The old approach was wrong and needed a rewrite.

Fix

Remove footer lines by matching whole lines instead of doing substring replacement, so only the real footer lines are stripped and body prose is left intact.

Testing

Added a test that fails before the change and passes after it. All existing conventional_commit tests still pass; dart format and dart analyze are clean on the touched files.

The body was computed by stripping each extracted footer from the body
with `String.replaceAll`, which removes every occurrence of that text
anywhere in the body, not just the trailing footer line. When a body
paragraph legitimately contains the same text as a footer (e.g. an inline
"Refs invertase#123" referenced in prose and again as a trailer), the inline
occurrence was silently deleted, corrupting the parsed body.

Remove footer lines by matching whole lines instead, so only the actual
footer lines are stripped and body prose is left intact.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@spydon

spydon commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Hey @amalsaidov, can you sign the CLA so that we can get this merged?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants