Skip to content

Commit

Permalink
feat(commit): add merge_commit flag to the context (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Dec 18, 2023
1 parent ee205c4 commit dd27a9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-cliff-core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ pub struct Commit<'a> {
pub author: Signature,
/// Committer.
pub committer: Signature,
/// Whether if the commit has two or more parents.
pub merge_commit: bool,
}

impl<'a> From<String> for Commit<'a> {
Expand Down Expand Up @@ -152,6 +154,7 @@ impl<'a> From<&GitCommit<'a>> for Commit<'a> {
message: commit.message().unwrap_or_default().to_string(),
author: commit.author().into(),
committer: commit.committer().into(),
merge_commit: commit.parent_count() > 1,
..Default::default()
}
}
Expand Down Expand Up @@ -414,6 +417,7 @@ impl Serialize for Commit<'_> {
commit.serialize_field("author", &self.author)?;
commit.serialize_field("committer", &self.committer)?;
commit.serialize_field("conventional", &self.conv.is_some())?;
commit.serialize_field("merge_commit", &self.merge_commit)?;
commit.end()
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/templating/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ following context is generated to use for templating:
"breaking_description": "<description>",
"breaking": false,
"conventional": true,
"merge_commit": false,
"links": [
{ "text": "(set by link_parsers)", "href": "(set by link_parsers)" }
],
Expand Down Expand Up @@ -129,6 +130,7 @@ If [`conventional_commits`](/docs/configuration#conventional_commits) is set to
"scope": "(overridden by commit_parsers)",
"message": "(full commit message including description, footers, etc.)",
"conventional": false,
"merge_commit": false,
"links": [
{ "text": "(set by link_parsers)", "href": "(set by link_parsers)" }
],
Expand Down

0 comments on commit dd27a9a

Please sign in to comment.