mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
feat: add support for rendering .Body after .Subject as part of list (#121)
When attempting to render a commit body below the summary line of the commit there are two problems: 1) The text needs to be indented two spaces to appear as part of the list. 2) Notes (e.g. BREAKING CHANGE) are included in the body and end up being repeating in a Notes section (if this is part of your template). To address #1 add an `indent` func to the template parsing. To address #2 add a `TrimmedBody` to the `Commit` fields. The `TrimmedBody` will include everything in `Body` but not any `Ref`s, `Note`s, `Mention`s, `CoAuthors`, or `Signers`. Both the CoAuthors and Signers are now first class in the Commit struct. With both of these a template block like: ``` {{ if .TrimmedBody -}} {{ indent .TrimmedBody 2 }} {{ end -}} ``` Will render the trimmed down body section as intended. See TestGeneratorWithTimmedBody for example of desired output.
This commit is contained in:
parent
2caa67cc76
commit
9a0d584745
6 changed files with 239 additions and 28 deletions
|
|
@ -103,13 +103,14 @@ func TestCommitParserParse(t *testing.T) {
|
|||
Source: "",
|
||||
},
|
||||
},
|
||||
Notes: []*Note{},
|
||||
Mentions: []string{},
|
||||
Header: "feat(*): Add new feature #123",
|
||||
Type: "feat",
|
||||
Scope: "*",
|
||||
Subject: "Add new feature #123",
|
||||
Body: "",
|
||||
Notes: []*Note{},
|
||||
Mentions: []string{},
|
||||
Header: "feat(*): Add new feature #123",
|
||||
Type: "feat",
|
||||
Scope: "*",
|
||||
Subject: "Add new feature #123",
|
||||
Body: "",
|
||||
TrimmedBody: "",
|
||||
},
|
||||
{
|
||||
Hash: &Hash{
|
||||
|
|
@ -166,6 +167,7 @@ Fixes #3
|
|||
Closes #1
|
||||
|
||||
BREAKING CHANGE: This is breaking point message.`,
|
||||
TrimmedBody: `This is body message.`,
|
||||
},
|
||||
{
|
||||
Hash: &Hash{
|
||||
|
|
@ -200,6 +202,7 @@ BREAKING CHANGE: This is breaking point message.`,
|
|||
@tsuyoshiwada
|
||||
@hogefuga
|
||||
@FooBarBaz`,
|
||||
TrimmedBody: `Has mention body`,
|
||||
},
|
||||
{
|
||||
Hash: &Hash{
|
||||
|
|
@ -280,6 +283,7 @@ class MyController extends Controller {
|
|||
|
||||
Fixes #123
|
||||
Closes username/repository#456`, "```", "```"),
|
||||
TrimmedBody: `This mixed body message.`,
|
||||
},
|
||||
{
|
||||
Hash: &Hash{
|
||||
|
|
@ -300,14 +304,15 @@ Closes username/repository#456`, "```", "```"),
|
|||
Revert: &Revert{
|
||||
Header: "fix(core): commit message",
|
||||
},
|
||||
Refs: []*Ref{},
|
||||
Notes: []*Note{},
|
||||
Mentions: []string{},
|
||||
Header: "Revert \"fix(core): commit message\"",
|
||||
Type: "",
|
||||
Scope: "",
|
||||
Subject: "",
|
||||
Body: "This reverts commit f755db78dcdf461dc42e709b3ab728ceba353d1d.",
|
||||
Refs: []*Ref{},
|
||||
Notes: []*Note{},
|
||||
Mentions: []string{},
|
||||
Header: "Revert \"fix(core): commit message\"",
|
||||
Type: "",
|
||||
Scope: "",
|
||||
Subject: "",
|
||||
Body: "This reverts commit f755db78dcdf461dc42e709b3ab728ceba353d1d.",
|
||||
TrimmedBody: "This reverts commit f755db78dcdf461dc42e709b3ab728ceba353d1d.",
|
||||
},
|
||||
}, commits)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue