mirror of
https://github.com/orhun/git-cliff.git
synced 2024-10-26 16:04:18 +03:00
fix(parser): allow matching empty commit body (#605)
This commit is contained in:
parent
c7001e9d13
commit
1d1b3b80e1
@ -262,11 +262,13 @@ impl Commit<'_> {
|
|||||||
if let Some(message_regex) = parser.message.as_ref() {
|
if let Some(message_regex) = parser.message.as_ref() {
|
||||||
regex_checks.push((message_regex, self.message.to_string()))
|
regex_checks.push((message_regex, self.message.to_string()))
|
||||||
}
|
}
|
||||||
if let (Some(body_regex), Some(body)) = (
|
let body = self
|
||||||
parser.body.as_ref(),
|
.conv
|
||||||
self.conv.as_ref().and_then(|v| v.body()),
|
.as_ref()
|
||||||
) {
|
.and_then(|v| v.body())
|
||||||
regex_checks.push((body_regex, body.to_string()))
|
.map(|v| v.to_string());
|
||||||
|
if let Some(body_regex) = parser.body.as_ref() {
|
||||||
|
regex_checks.push((body_regex, body.clone().unwrap_or_default()))
|
||||||
}
|
}
|
||||||
if let (Some(field_name), Some(pattern_regex)) =
|
if let (Some(field_name), Some(pattern_regex)) =
|
||||||
(parser.field.as_ref(), parser.pattern.as_ref())
|
(parser.field.as_ref(), parser.pattern.as_ref())
|
||||||
@ -276,11 +278,7 @@ impl Commit<'_> {
|
|||||||
match field_name.as_str() {
|
match field_name.as_str() {
|
||||||
"id" => Some(self.id.clone()),
|
"id" => Some(self.id.clone()),
|
||||||
"message" => Some(self.message.clone()),
|
"message" => Some(self.message.clone()),
|
||||||
"body" => self
|
"body" => body,
|
||||||
.conv
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|v| v.body())
|
|
||||||
.map(|v| v.to_string()),
|
|
||||||
"author.name" => self.author.name.clone(),
|
"author.name" => self.author.name.clone(),
|
||||||
"author.email" => self.author.email.clone(),
|
"author.email" => self.author.email.clone(),
|
||||||
"committer.name" => self.committer.name.clone(),
|
"committer.name" => self.committer.name.clone(),
|
||||||
|
@ -60,3 +60,12 @@ commit_preprocessors = [
|
|||||||
{ pattern = ' *(:\w+:|[\p{Emoji_Presentation}\p{Extended_Pictographic}](?:\u{FE0F})?\u{200D}?) *', replace = "" },
|
{ pattern = ' *(:\w+:|[\p{Emoji_Presentation}\p{Extended_Pictographic}](?:\u{FE0F})?\u{200D}?) *', replace = "" },
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Skip commits with an empty body
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[git]
|
||||||
|
commit_parsers = [
|
||||||
|
{ body = "$^", skip = true },
|
||||||
|
]
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user