0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-10 02:10:38 +00:00
git-sv/sv/helpers_test.go

52 lines
1.3 KiB
Go
Raw Normal View History

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
)
func version(v string) *semver.Version {
2019-11-17 17:43:01 +00:00
r, _ := semver.NewVersion(v)
return r
2019-11-17 17:43:01 +00:00
}
func commitlog(ctype string, metadata map[string]string, author string) GitCommitLog {
breaking := false
if _, found := metadata[breakingChangeMetadataKey]; found {
breaking = true
}
2019-11-17 17:43:01 +00:00
return GitCommitLog{
Message: CommitMessage{
Type: ctype,
Description: "subject text",
IsBreakingChange: breaking,
Metadata: metadata,
},
AuthorName: author,
2019-11-17 17:43:01 +00:00
}
}
func releaseNote(version *semver.Version, tag string, date time.Time, sections map[string]ReleaseNoteSection, breakingChanges []string, authorsNames map[string]struct{}) ReleaseNote {
var bchanges BreakingChangeSection
if len(breakingChanges) > 0 {
bchanges = BreakingChangeSection{Name: "Breaking Changes", Messages: breakingChanges}
}
2019-11-17 17:43:01 +00:00
return ReleaseNote{
Version: version,
Tag: tag,
Date: date.Truncate(time.Minute),
2019-11-17 17:43:01 +00:00
Sections: sections,
BreakingChanges: bchanges,
AuthorsNames: authorsNames,
2019-11-17 17:43:01 +00:00
}
}
func newReleaseNoteSection(name string, types []string, items []GitCommitLog) ReleaseNoteSection {
2019-11-17 17:43:01 +00:00
return ReleaseNoteSection{
Name: name,
Types: types,
2019-11-17 17:43:01 +00:00
Items: items,
}
}