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
|
|
@ -8,6 +8,12 @@ type Hash struct {
|
|||
Short string
|
||||
}
|
||||
|
||||
// Contact of co-authors and signers
|
||||
type Contact struct {
|
||||
Name string
|
||||
Email string
|
||||
}
|
||||
|
||||
// Author of commit
|
||||
type Author struct {
|
||||
Name string
|
||||
|
|
@ -70,6 +76,8 @@ type Commit struct {
|
|||
Refs []*Ref
|
||||
Notes []*Note
|
||||
Mentions []string // Name of the user included in the commit header or body
|
||||
CoAuthors []Contact // (e.g. `Co-authored-by: user <user@email>`)
|
||||
Signers []Contact // (e.g. `Signed-off-by: user <user@email>`)
|
||||
JiraIssue *JiraIssue // If no issue id found in header, `nil` is assigned
|
||||
Header string // (e.g. `feat(core)[RNWY-310]: Add new feature`)
|
||||
Type string // (e.g. `feat`)
|
||||
|
|
@ -77,6 +85,7 @@ type Commit struct {
|
|||
Subject string // (e.g. `Add new feature`)
|
||||
JiraIssueID string // (e.g. `RNWY-310`)
|
||||
Body string
|
||||
TrimmedBody string // Body without any Notes/Refs/Mentions/CoAuthors/Signers
|
||||
}
|
||||
|
||||
// CommitGroup is a collection of commits grouped according to the `CommitGroupBy` option
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue