Skip to content

fix: parse multi-line commit messages without errors#83

Merged
zachdaniel merged 3 commits intozachdaniel:masterfrom
jimsynz:fix/multi-line-commits
Apr 8, 2026
Merged

fix: parse multi-line commit messages without errors#83
zachdaniel merged 3 commits intozachdaniel:masterfrom
jimsynz:fix/multi-line-commits

Conversation

@jimsynz
Copy link
Copy Markdown
Contributor

@jimsynz jimsynz commented Apr 7, 2026

Summary

  • Refactors Commit.parse/2 to parse commit messages line-by-line instead of passing the full text to NimbleParsec
  • The first line must be a valid conventional commit or the parse fails
  • Remaining lines are tried individually: parseable lines become additional commits, unparseable lines become body text for the preceding commit
  • Fixes parse failures on multi-line commits (especially dependabot) where body text like dependency-type: direct:production was misinterpreted as a conventional commit pattern

Test plan

  • All 19 existing tests pass unchanged
  • Added test for dependabot-style commit with complex YAML body
  • Added test for body/footer extraction from multi-line messages
  • Added test for BREAKING CHANGE: detection in body
  • Added test that non-conventional first line returns :error

jimsynz added 2 commits April 7, 2026 14:16
…mit header

Previously, the entire multi-line commit message was passed to the
NimbleParsec parser, which would misinterpret body text (e.g. dependabot
YAML metadata like `dependency-type: direct:production`) as additional
conventional commits, causing parse failures.

Now the parser splits messages line-by-line: the first line must parse as
a valid conventional commit or the whole message is rejected. Remaining
lines are tried individually — successful parses become additional commits,
failures become body text for the preceding commit.

commit = parse_one!(text)
assert commit.breaking?
assert commit.body == "BREAKING CHANGE: The v1 API has been removed."
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Should the "Users must migrate to v2." not be considered part of the body?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

.gitignore Outdated

/.elixir_ls/
/.elixir-tools/
.claude
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I typically prefer to keep these out of our project's gitignore files in favor of them living in people's personal settings.

Previously `build_commit` split body lines into separate `body` and
`footer` fields, losing content beyond the second paragraph. Now all
non-header lines are joined into `body`. Also disables GitHub API
lookups in release tests to prevent rate-limit-induced timeouts.
@jimsynz jimsynz force-pushed the fix/multi-line-commits branch from deb04c2 to f9dbcc3 Compare April 8, 2026 02:17
@zachdaniel zachdaniel merged commit d90ae56 into zachdaniel:master Apr 8, 2026
@zachdaniel
Copy link
Copy Markdown
Owner

🚀 Thank you for your contribution! 🚀

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.

2 participants