This commit is contained in:
hackerman 2025-03-29 20:32:31 +00:00 committed by GitHub
commit 9e7fc26d61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ package chglog
import (
"sort"
"strings"
"time"
)
type commitExtractor struct {
@ -114,14 +115,26 @@ func (e *commitExtractor) commitGroupTitle(commit *Commit) (string, string) {
)
if title, ok := dotGet(commit, e.opts.CommitGroupBy); ok {
if v, ok := title.(string); ok {
raw = v
if t, ok := e.opts.CommitGroupTitleMaps[v]; ok {
ttl = t
} else {
//nolint:staticcheck
ttl = strings.Title(raw)
}
switch titleType := title.(type) {
case string:
raw = titleType
case time.Time:
raw = titleType.Format("2006-01-02")
case *time.Time:
raw = titleType.Format("2006-01-02")
case interface {
String() string
}:
raw = titleType.String()
default:
return "", ""
}
if t, ok := e.opts.CommitGroupTitleMaps[raw]; ok {
ttl = t
} else {
//nolint:staticcheck
ttl = strings.Title(raw)
}
}