mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-25 07:30: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
|
Version string
|
||||||
Date string
|
Date string
|
||||||
Sections map[string]ReleaseNoteSection
|
Sections map[string]ReleaseNoteSection
|
||||||
BreakingChanges []string
|
BreakingChanges BreakingChangeSection
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -32,10 +32,10 @@ const (
|
|||||||
{{- end}}
|
{{- end}}
|
||||||
{{- end}}`
|
{{- end}}`
|
||||||
|
|
||||||
rnSectionBreakingChanges = `{{- if .}}
|
rnSectionBreakingChanges = `{{- if ne .Name ""}}
|
||||||
|
|
||||||
### Breaking Changes
|
### {{.Name}}
|
||||||
{{range $k,$v := .}}
|
{{range $k,$v := .Messages}}
|
||||||
- {{$v}}
|
- {{$v}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{- end}}`
|
{{- end}}`
|
||||||
|
@ -11,14 +11,14 @@ func version(v string) semver.Version {
|
|||||||
return *r
|
return *r
|
||||||
}
|
}
|
||||||
|
|
||||||
func commitlog(t string, metadata map[string]string) GitCommitLog {
|
func commitlog(ctype string, metadata map[string]string) GitCommitLog {
|
||||||
breaking := false
|
breaking := false
|
||||||
if _, found := metadata[breakingChangeMetadataKey]; found {
|
if _, found := metadata[breakingChangeMetadataKey]; found {
|
||||||
breaking = true
|
breaking = true
|
||||||
}
|
}
|
||||||
return GitCommitLog{
|
return GitCommitLog{
|
||||||
Message: CommitMessage{
|
Message: CommitMessage{
|
||||||
Type: t,
|
Type: ctype,
|
||||||
Description: "subject text",
|
Description: "subject text",
|
||||||
IsBreakingChange: breaking,
|
IsBreakingChange: breaking,
|
||||||
Metadata: metadata,
|
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 {
|
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{
|
return ReleaseNote{
|
||||||
Version: version,
|
Version: version,
|
||||||
Date: date.Truncate(time.Minute),
|
Date: date.Truncate(time.Minute),
|
||||||
Sections: sections,
|
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.
|
// ReleaseNote release note.
|
||||||
@ -48,7 +52,13 @@ type ReleaseNote struct {
|
|||||||
Version *semver.Version
|
Version *semver.Version
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Sections map[string]ReleaseNoteSection
|
Sections map[string]ReleaseNoteSection
|
||||||
BreakingChanges []string
|
BreakingChanges BreakingChangeSection
|
||||||
|
}
|
||||||
|
|
||||||
|
// BreakingChangeSection breaking change section
|
||||||
|
type BreakingChangeSection struct {
|
||||||
|
Name string
|
||||||
|
Messages []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseNoteSection release note section.
|
// ReleaseNoteSection release note section.
|
||||||
|
@ -42,7 +42,7 @@ func TestReleaseNoteProcessorImpl_Create(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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) {
|
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)
|
t.Errorf("ReleaseNoteProcessorImpl.Create() = %v, want %v", got, tt.want)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user