mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-10 02:10:38 +00:00
feat: add support to rename or disable breaking changes section from release notes
This commit is contained in:
parent
253b77d061
commit
11a847fe22
@ -10,7 +10,7 @@ type releaseNoteTemplateVariables struct {
|
||||
Version string
|
||||
Date string
|
||||
Sections map[string]ReleaseNoteSection
|
||||
BreakingChanges []string
|
||||
BreakingChanges BreakingChangeSection
|
||||
}
|
||||
|
||||
const (
|
||||
@ -32,10 +32,10 @@ const (
|
||||
{{- end}}
|
||||
{{- end}}`
|
||||
|
||||
rnSectionBreakingChanges = `{{- if .}}
|
||||
rnSectionBreakingChanges = `{{- if ne .Name ""}}
|
||||
|
||||
### Breaking Changes
|
||||
{{range $k,$v := .}}
|
||||
### {{.Name}}
|
||||
{{range $k,$v := .Messages}}
|
||||
- {{$v}}
|
||||
{{- end}}
|
||||
{{- end}}`
|
||||
|
@ -11,14 +11,14 @@ func version(v string) semver.Version {
|
||||
return *r
|
||||
}
|
||||
|
||||
func commitlog(t string, metadata map[string]string) GitCommitLog {
|
||||
func commitlog(ctype string, metadata map[string]string) GitCommitLog {
|
||||
breaking := false
|
||||
if _, found := metadata[breakingChangeMetadataKey]; found {
|
||||
breaking = true
|
||||
}
|
||||
return GitCommitLog{
|
||||
Message: CommitMessage{
|
||||
Type: t,
|
||||
Type: ctype,
|
||||
Description: "subject text",
|
||||
IsBreakingChange: breaking,
|
||||
Metadata: metadata,
|
||||
@ -27,11 +27,15 @@ func commitlog(t string, metadata map[string]string) GitCommitLog {
|
||||
}
|
||||
|
||||
func releaseNote(version *semver.Version, date time.Time, sections map[string]ReleaseNoteSection, breakingChanges []string) ReleaseNote {
|
||||
var bchanges BreakingChangeSection
|
||||
if len(breakingChanges) > 0 {
|
||||
bchanges = BreakingChangeSection{Name: "Breaking Changes", Messages: breakingChanges}
|
||||
}
|
||||
return ReleaseNote{
|
||||
Version: version,
|
||||
Date: date.Truncate(time.Minute),
|
||||
Sections: sections,
|
||||
BreakingChanges: breakingChanges,
|
||||
BreakingChanges: bchanges,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,11 @@ func (p ReleaseNoteProcessorImpl) Create(version *semver.Version, date time.Time
|
||||
}
|
||||
}
|
||||
|
||||
return ReleaseNote{Version: version, Date: date.Truncate(time.Minute), Sections: sections, BreakingChanges: breakingChanges}
|
||||
var breakingChangeSection BreakingChangeSection
|
||||
if name, exists := p.cfg.Headers[breakingChangeMetadataKey]; exists && len(breakingChanges) > 0 {
|
||||
breakingChangeSection = BreakingChangeSection{Name: name, Messages: breakingChanges}
|
||||
}
|
||||
return ReleaseNote{Version: version, Date: date.Truncate(time.Minute), Sections: sections, BreakingChanges: breakingChangeSection}
|
||||
}
|
||||
|
||||
// ReleaseNote release note.
|
||||
@ -48,7 +52,13 @@ type ReleaseNote struct {
|
||||
Version *semver.Version
|
||||
Date time.Time
|
||||
Sections map[string]ReleaseNoteSection
|
||||
BreakingChanges []string
|
||||
BreakingChanges BreakingChangeSection
|
||||
}
|
||||
|
||||
// BreakingChangeSection breaking change section
|
||||
type BreakingChangeSection struct {
|
||||
Name string
|
||||
Messages []string
|
||||
}
|
||||
|
||||
// ReleaseNoteSection release note section.
|
||||
|
@ -42,7 +42,7 @@ func TestReleaseNoteProcessorImpl_Create(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := NewReleaseNoteProcessor(ReleaseNotesConfig{Headers: map[string]string{"t1": "Tag 1", "t2": "Tag 2"}})
|
||||
p := NewReleaseNoteProcessor(ReleaseNotesConfig{Headers: map[string]string{"t1": "Tag 1", "t2": "Tag 2", "breaking-change": "Breaking Changes"}})
|
||||
if got := p.Create(tt.version, tt.date, tt.commits); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("ReleaseNoteProcessorImpl.Create() = %v, want %v", got, tt.want)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user