mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 10:25:24 +00:00
Merge 9afe82584f into 83fc0386ad
This commit is contained in:
commit
6498658029
5 changed files with 51 additions and 6 deletions
14
README.md
14
README.md
|
|
@ -480,6 +480,13 @@ The basic templates are as follows.
|
|||
{{ end }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- if .Unreleased.OtherCommits -}}
|
||||
### Others
|
||||
{{ range .Unreleased.OtherCommits -}}
|
||||
- {{ .Header }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ range .Versions }}
|
||||
|
|
@ -514,6 +521,13 @@ The basic templates are as follows.
|
|||
{{ end }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- if .OtherCommits -}}
|
||||
### Others
|
||||
{{ range .OtherCommits -}}
|
||||
- {{ .Header }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- if .Versions }}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ func (gen *Generator) readVersions(tags []*Tag, first string) ([]*Version, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
commitGroups, mergeCommits, revertCommits, noteGroups := gen.commitExtractor.Extract(commits)
|
||||
commitGroups, mergeCommits, revertCommits, otherCommits, noteGroups := gen.commitExtractor.Extract(commits)
|
||||
|
||||
versions = append(versions, &Version{
|
||||
Tag: tag,
|
||||
|
|
@ -211,6 +211,7 @@ func (gen *Generator) readVersions(tags []*Tag, first string) ([]*Version, error
|
|||
Commits: commits,
|
||||
MergeCommits: mergeCommits,
|
||||
RevertCommits: revertCommits,
|
||||
OtherCommits: otherCommits,
|
||||
NoteGroups: noteGroups,
|
||||
})
|
||||
|
||||
|
|
@ -239,13 +240,14 @@ func (gen *Generator) readUnreleased(tags []*Tag) (*Unreleased, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
commitGroups, mergeCommits, revertCommits, noteGroups := gen.commitExtractor.Extract(commits)
|
||||
commitGroups, mergeCommits, revertCommits, otherCommits, noteGroups := gen.commitExtractor.Extract(commits)
|
||||
|
||||
unreleased := &Unreleased{
|
||||
CommitGroups: commitGroups,
|
||||
Commits: commits,
|
||||
MergeCommits: mergeCommits,
|
||||
RevertCommits: revertCommits,
|
||||
OtherCommits: otherCommits,
|
||||
NoteGroups: noteGroups,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@ func newCommitExtractor(opts *Options) *commitExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
func (e *commitExtractor) Extract(commits []*Commit) ([]*CommitGroup, []*Commit, []*Commit, []*NoteGroup) {
|
||||
func (e *commitExtractor) Extract(commits []*Commit) ([]*CommitGroup, []*Commit, []*Commit, []*Commit, []*NoteGroup) {
|
||||
commitGroups := []*CommitGroup{}
|
||||
noteGroups := []*NoteGroup{}
|
||||
mergeCommits := []*Commit{}
|
||||
revertCommits := []*Commit{}
|
||||
otherCommits := []*Commit{}
|
||||
|
||||
filteredCommits := commitFilter(commits, e.opts.CommitFilters, e.opts.NoCaseSensitive)
|
||||
|
||||
|
|
@ -33,6 +34,10 @@ func (e *commitExtractor) Extract(commits []*Commit) ([]*CommitGroup, []*Commit,
|
|||
revertCommits = append(revertCommits, commit)
|
||||
continue
|
||||
}
|
||||
|
||||
if commit.Type == "" {
|
||||
otherCommits = append(otherCommits, commit)
|
||||
}
|
||||
}
|
||||
|
||||
for _, commit := range filteredCommits {
|
||||
|
|
@ -46,7 +51,7 @@ func (e *commitExtractor) Extract(commits []*Commit) ([]*CommitGroup, []*Commit,
|
|||
e.sortCommitGroups(commitGroups)
|
||||
e.sortNoteGroups(noteGroups)
|
||||
|
||||
return commitGroups, mergeCommits, revertCommits, noteGroups
|
||||
return commitGroups, mergeCommits, revertCommits, otherCommits, noteGroups
|
||||
}
|
||||
|
||||
func (e *commitExtractor) processCommitGroups(groups *[]*CommitGroup, commit *Commit, noCaseSensitive bool) {
|
||||
|
|
|
|||
|
|
@ -76,9 +76,16 @@ func TestCommitExtractor(t *testing.T) {
|
|||
Header: "REVERT1",
|
||||
},
|
||||
},
|
||||
// [6]
|
||||
{
|
||||
Type: "",
|
||||
Scope: "",
|
||||
Header: "Other",
|
||||
Notes: []*Note{},
|
||||
},
|
||||
}
|
||||
|
||||
commitGroups, mergeCommits, revertCommits, noteGroups := extractor.Extract(fixtures)
|
||||
commitGroups, mergeCommits, revertCommits, otherCommits, noteGroups := extractor.Extract(fixtures)
|
||||
|
||||
assert.Equal([]*CommitGroup{
|
||||
{
|
||||
|
|
@ -107,6 +114,10 @@ func TestCommitExtractor(t *testing.T) {
|
|||
fixtures[5],
|
||||
}, revertCommits)
|
||||
|
||||
assert.Equal([]*Commit{
|
||||
fixtures[6],
|
||||
}, otherCommits)
|
||||
|
||||
assert.Equal([]*NoteGroup{
|
||||
{
|
||||
Title: "note1-title",
|
||||
|
|
@ -207,9 +218,16 @@ func TestCommitOrderExtractor(t *testing.T) {
|
|||
Header: "REVERT1",
|
||||
},
|
||||
},
|
||||
// [6]
|
||||
{
|
||||
Type: "",
|
||||
Scope: "",
|
||||
Header: "Other",
|
||||
Notes: []*Note{},
|
||||
},
|
||||
}
|
||||
|
||||
commitGroups, mergeCommits, revertCommits, noteGroups := extractor.Extract(fixtures)
|
||||
commitGroups, mergeCommits, revertCommits, otherCommits, noteGroups := extractor.Extract(fixtures)
|
||||
|
||||
assert.Equal([]*CommitGroup{
|
||||
{
|
||||
|
|
@ -238,6 +256,10 @@ func TestCommitOrderExtractor(t *testing.T) {
|
|||
fixtures[5],
|
||||
}, revertCommits)
|
||||
|
||||
assert.Equal([]*Commit{
|
||||
fixtures[6],
|
||||
}, otherCommits)
|
||||
|
||||
assert.Equal([]*NoteGroup{
|
||||
{
|
||||
Title: "note1-title",
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ type Version struct {
|
|||
Commits []*Commit
|
||||
MergeCommits []*Commit
|
||||
RevertCommits []*Commit
|
||||
OtherCommits []*Commit
|
||||
NoteGroups []*NoteGroup
|
||||
}
|
||||
|
||||
|
|
@ -129,5 +130,6 @@ type Unreleased struct {
|
|||
Commits []*Commit
|
||||
MergeCommits []*Commit
|
||||
RevertCommits []*Commit
|
||||
OtherCommits []*Commit
|
||||
NoteGroups []*NoteGroup
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue