feat: Adds 'Custom' sort_type to CommitGroup (#69)

Closes #60
This commit is contained in:
Khosrow Moossavi 2021-01-09 17:11:18 -05:00 committed by GitHub
parent 75d59a9eb8
commit 44f71cbcd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 192 additions and 44 deletions

View file

@ -128,8 +128,19 @@ func (e *commitExtractor) commitGroupTitle(commit *Commit) (string, string) {
}
func (e *commitExtractor) sortCommitGroups(groups []*CommitGroup) {
order := make(map[string]int)
if e.opts.CommitGroupSortBy == "Custom" {
for i, t := range e.opts.CommitGroupTitleOrder {
order[t] = i
}
}
// groups
sort.Slice(groups, func(i, j int) bool {
if e.opts.CommitGroupSortBy == "Custom" {
return order[groups[i].RawTitle] < order[groups[j].RawTitle]
}
var (
a, b interface{}
ok bool