2024-08-31 15:23:21 +02:00
|
|
|
package commitparser
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/apricote/releaser-pleaser/internal/git"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CommitParser interface {
|
|
|
|
|
Analyze(commits []git.Commit) ([]AnalyzedCommit, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AnalyzedCommit struct {
|
|
|
|
|
git.Commit
|
|
|
|
|
Type string
|
|
|
|
|
Description string
|
|
|
|
|
Scope *string
|
|
|
|
|
BreakingChange bool
|
|
|
|
|
}
|
2024-09-22 14:00:30 +02:00
|
|
|
|
|
|
|
|
// ByType groups the Commits by the type field. Used by the Changelog.
|
|
|
|
|
func ByType(in []AnalyzedCommit) map[string][]AnalyzedCommit {
|
|
|
|
|
out := map[string][]AnalyzedCommit{}
|
|
|
|
|
|
|
|
|
|
for _, commit := range in {
|
|
|
|
|
if out[commit.Type] == nil {
|
|
|
|
|
out[commit.Type] = make([]AnalyzedCommit, 0, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out[commit.Type] = append(out[commit.Type], commit)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
}
|