Skip to content

Commit

Permalink
feat(changelog)!: use conventional commit body to check against commi…
Browse files Browse the repository at this point in the history
…t parsers
  • Loading branch information
orhun committed Feb 5, 2022
1 parent a3f3aa6 commit e1da611
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions git-cliff-core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ impl Commit<'_> {
/// [`scope`]: Commit::scope
pub fn parse(mut self, parsers: &[CommitParser], filter: bool) -> Result<Self> {
for parser in parsers {
for regex in vec![parser.message.as_ref(), parser.body.as_ref()]
.into_iter()
.flatten()
{
if regex.is_match(&self.message) {
let mut regex_checks = Vec::new();
if let Some(message_regex) = parser.message.as_ref() {
regex_checks.push((message_regex, self.message.to_string()))
}
if let (Some(body_regex), Some(body)) = (
parser.body.as_ref(),
self.conv.as_ref().and_then(|v| v.body()),
) {
regex_checks.push((body_regex, body.to_string()))
}
for (regex, text) in regex_checks {
if regex.is_match(&text) {
if parser.skip != Some(true) {
self.group = parser.group.as_ref().cloned();
self.scope = parser.default_scope.as_ref().cloned();
Expand Down

0 comments on commit e1da611

Please sign in to comment.