Skip to content

Commit

Permalink
add warning emoji for changelog lineitem
Browse files Browse the repository at this point in the history
  • Loading branch information
HandOfGod94 committed Jun 26, 2023
1 parent 937e2d8 commit 269dba9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/jira_changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
var changeLogTmpl embed.FS

type Changelog struct {
DoneChanges map[string][]jira.Issue
Changes map[string][]jira.Issue
}

func (c *Changelog) Render(w io.Writer) {
Expand Down
29 changes: 21 additions & 8 deletions pkg/jira_changelog/changelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestRender(t *testing.T) {
{
desc: "when there are `done` issues",
changelog: jira_changelog.Changelog{
DoneChanges: map[string][]jira.Issue{
Changes: map[string][]jira.Issue{
"TestEpic": {
jira.NewIssue("TEST-1", "foobar is new"),
jira.NewIssue("TEST-2", "fizzbuzz is something else"),
jira.NewIssue("TEST-1", "foobar is new", "done"),
jira.NewIssue("TEST-2", "fizzbuzz is something else", "done"),
},
},
},
Expand All @@ -30,14 +30,27 @@ func TestRender(t *testing.T) {
### TestEpic
- [TEST-1] foobar is new
- [TEST-2] fizzbuzz is something else
`,
},
{
desc: "when there are `wip` issues",
changelog: jira_changelog.Changelog{
Changes: map[string][]jira.Issue{
"TestEpic": {
jira.NewIssue("TEST-1", "foobar is new", "done"),
jira.NewIssue("TEST-2", "fizzbuzz is something else", "in progress"),
jira.NewIssue("TEST-3", "fizzbuzz is something else", "done"),
},
},
},
want: `## What has changed?
## :warning: WIP
### These cards are still in "done" state. Be careful while examining it
### TestEpic
- [TEST-1] foobar is new
- :warning: [TEST-2] fizzbuzz is something else
- [TEST-3] fizzbuzz is something else
`,
},
// {
// desc: "when there are `wip` issues",
// },
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jira_changelog/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c Generator) Generate() *Changelog {

issuesByEpic := lo.GroupBy(issues, func(issue jira.Issue) string { return issue.Epic() })
slog.Debug("Issues grouped by epic", "issues", issuesByEpic)
return &Changelog{DoneChanges: issuesByEpic}
return &Changelog{Changes: issuesByEpic}
}

func NewGenerator(jiraConfig jira.Config, fromRef, toRef string) *Generator {
Expand Down
3 changes: 2 additions & 1 deletion pkg/jira_changelog/jira/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ type Issue struct {
} `json:"fields"`
}

func NewIssue(key, summary string) Issue {
func NewIssue(key, summary string, status string) Issue {
issues := &Issue{}
issues.Key = key
issues.Fields.Summary = summary
issues.Fields.Status.StatusCategory.Key = status
return *issues
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/jira_changelog/templates/changelog.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## What has changed?
{{ range $epic, $changes := .DoneChanges }}
{{ range $epic, $changes := .Changes }}
### {{$epic}}
{{- range $index, $change := $changes }}
{{- if $change.IsWip }}
- :warning: [{{$change.Key}}] {{$change.Fields.Summary -}}
{{- else }}
- [{{$change.Key}}] {{$change.Fields.Summary -}}
{{- end -}}
{{ end -}}
{{ end }}

## :warning: WIP
### These cards are still in "done" state. Be careful while examining it

0 comments on commit 269dba9

Please sign in to comment.