-
Notifications
You must be signed in to change notification settings - Fork 10
Line parsed as body even if missing empty line #51
Copy link
Copy link
Open
Description
Steps to Reproduce
- package.json :
{
"name": "commitlint-parser-test",
"scripts": {
"start": "node analyze-commits.js"
},
"type": "module",
"dependencies": {
"conventional-commits-parser": "6.3.0"
}
}
- analyze-commits.js:
import { CommitParser } from "conventional-commits-parser";
function analyzeCommitMessage() {
const message = `feat(core): some subject with
its second line under with only one carriage return
A body`;
console.log("Commit Message:");
console.log(message);
const parser = new CommitParser();
const parsed = parser.parse(message);
console.log("\nParsed component:");
console.log(JSON.stringify(parsed, null, 2));
}
analyzeCommitMessage();
and starts with npm run start
Current Behavior
The result is :
{
"type": "feat",
"scope": "core",
"subject": "some subject with" <=================================
"body": " its second line under with only one carriage return\n\n A body", <=====
"merge": null,
"revert": null,
"header": "feat(core): some subject with",
"footer": null,
"notes": [],
"mentions": [],
"references": [],
}
Expected Behavior
{
"type": "feat",
"scope": "core",
"subject": "some subject with\nits second line under with only one carriage return" <====
"body": "A body", <=============================================
"merge": null,
"revert": null,
"header": "feat(core): some subject with",
"footer": null,
"notes": [],
"mentions": [],
"references": [],
}
Context
Following convention commit specs :
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
optional body is after a blank line
So I'm not sure that's correct to consider that the body start after the subject new line, could it be blank or not
git --version
git version 2.52.0
node --version
v24.13.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels