Skip to content

Commit 037a010

Browse files
feat(reporting): add changelog issues report
1 parent 75d7437 commit 037a010

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

reporting/output.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,21 @@ func createOutputFile() (*os.File, error) {
3333
return outputFile, nil
3434
}
3535

36-
func writeChangelog(data string, outputFile *os.File) error {
37-
if opts.format == "json" {
38-
data = jsonFormat(data)
36+
func writeChangelog(issues []*github.Issue, outputFile *os.File) error {
37+
var issuesTable [][]string
38+
for _, issue := range issues {
39+
issuesTable = append(issuesTable, []string{issue.GetTitle(), issue.GetURL(), issue.GetUser().GetLogin()})
40+
}
41+
42+
markdownTable, err := markdown.NewTableFormatterBuilder().
43+
Build("Title", "Link to Body", "Assignee").
44+
Format(issuesTable)
45+
if err != nil {
46+
return err
3947
}
40-
_, err := outputFile.WriteString(data)
48+
result := fmt.Sprintf("# Changelog\n\nThere is **%d new closed issues** in gnolang/gno since %s\n\n%s", len(issues), opts.since, markdownTable)
49+
50+
_, err = outputFile.WriteString(result)
4151
if err != nil {
4252
return err
4353
}

reporting/reporting.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"encoding/json"
65
"flag"
76
"fmt"
87
"github.com/google/go-github/v50/github"
@@ -118,7 +117,7 @@ func fetchChangelog(client *github.Client, since time.Time, outputFile *os.File)
118117
if err != nil {
119118
return err
120119
}
121-
_, err = json.Marshal(issues)
120+
err = writeChangelog(issues, outputFile)
122121
if err != nil {
123122
return err
124123
}

0 commit comments

Comments
 (0)