Skip to content

Commit

Permalink
fix: keep newline in multiline footers
Browse files Browse the repository at this point in the history
Refs: #221
  • Loading branch information
hdevalke committed Apr 21, 2024
1 parent e4e1c83 commit 6500807
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/conventional/commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ impl CommitParser {
body.push_str(line);
body.push('\n');
} else if let Some(footer) = footers.last_mut() {
footer.value.push_str(line);
footer.value.push('\n');
footer.value.push_str(line);
}
for captures in self.regex_references.captures_iter(line) {
let prefix = &captures[1];
Expand Down Expand Up @@ -372,6 +372,16 @@ mod tests {
assert!(commit.is_breaking());
}

#[test]
fn test_with_breaking_footer_newline() {
let msg = "feat: allow provided config object to extend other configs\n\
\n\
BREAKING-CHANGE: `extends` key in config\nfile is now used for extending other config files";
let commit: Commit = parser().parse(msg).expect("valid");
assert!(commit.is_breaking());
assert_eq!(commit.footers.first().unwrap().value, "`extends` key in config\nfile is now used for extending other config files")
}

#[test]
fn test_with_multi_body_and_footer() {
let msg = "fix: correct minor typos in code\n\
Expand Down

0 comments on commit 6500807

Please sign in to comment.