2019-11-17 17:43:01 +00:00
|
|
|
package sv
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2021-02-13 18:40:09 +00:00
|
|
|
"github.com/Masterminds/semver/v3"
|
2019-11-17 17:43:01 +00:00
|
|
|
)
|
|
|
|
|
2021-12-29 21:02:50 +00:00
|
|
|
func version(v string) *semver.Version {
|
2019-11-17 17:43:01 +00:00
|
|
|
r, _ := semver.NewVersion(v)
|
2021-12-29 21:02:50 +00:00
|
|
|
return r
|
2019-11-17 17:43:01 +00:00
|
|
|
}
|
|
|
|
|
2021-02-15 04:47:20 +00:00
|
|
|
func commitlog(ctype string, metadata map[string]string) GitCommitLog {
|
2021-02-14 02:35:31 +00:00
|
|
|
breaking := false
|
2021-02-15 03:05:43 +00:00
|
|
|
if _, found := metadata[breakingChangeMetadataKey]; found {
|
2021-02-14 02:35:31 +00:00
|
|
|
breaking = true
|
|
|
|
}
|
2019-11-17 17:43:01 +00:00
|
|
|
return GitCommitLog{
|
2021-02-14 02:35:31 +00:00
|
|
|
Message: CommitMessage{
|
2021-02-15 04:47:20 +00:00
|
|
|
Type: ctype,
|
2021-02-14 02:35:31 +00:00
|
|
|
Description: "subject text",
|
|
|
|
IsBreakingChange: breaking,
|
|
|
|
Metadata: metadata,
|
|
|
|
},
|
2019-11-17 17:43:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-29 21:02:50 +00:00
|
|
|
func releaseNote(version *semver.Version, tag string, date time.Time, sections map[string]ReleaseNoteSection, breakingChanges []string) ReleaseNote {
|
2021-02-15 04:47:20 +00:00
|
|
|
var bchanges BreakingChangeSection
|
|
|
|
if len(breakingChanges) > 0 {
|
|
|
|
bchanges = BreakingChangeSection{Name: "Breaking Changes", Messages: breakingChanges}
|
|
|
|
}
|
2019-11-17 17:43:01 +00:00
|
|
|
return ReleaseNote{
|
2020-02-02 00:00:53 +00:00
|
|
|
Version: version,
|
2021-12-29 21:02:50 +00:00
|
|
|
Tag: tag,
|
2020-02-01 21:19:38 +00:00
|
|
|
Date: date.Truncate(time.Minute),
|
2019-11-17 17:43:01 +00:00
|
|
|
Sections: sections,
|
2021-02-15 04:47:20 +00:00
|
|
|
BreakingChanges: bchanges,
|
2019-11-17 17:43:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-02 02:51:29 +00:00
|
|
|
func newReleaseNoteSection(name string, items []GitCommitLog) ReleaseNoteSection {
|
2019-11-17 17:43:01 +00:00
|
|
|
return ReleaseNoteSection{
|
|
|
|
Name: name,
|
|
|
|
Items: items,
|
|
|
|
}
|
|
|
|
}
|