diff --git a/pkg/search/result.go b/pkg/search/result.go index 487eb7756..92de55113 100644 --- a/pkg/search/result.go +++ b/pkg/search/result.go @@ -213,8 +213,10 @@ func (issue Issue) ExportData(fields []string) map[string]interface{} { data[f] = labels case "repository": comp := strings.Split(issue.RepositoryURL, "/") + name := comp[len(comp)-1] nameWithOwner := strings.Join(comp[len(comp)-2:], "/") data[f] = map[string]interface{}{ + "name": name, "nameWithOwner": nameWithOwner, } default: diff --git a/pkg/search/result_test.go b/pkg/search/result_test.go index 15f00d98f..ba173e591 100644 --- a/pkg/search/result_test.go +++ b/pkg/search/result_test.go @@ -55,17 +55,18 @@ func TestIssueExportData(t *testing.T) { }{ { name: "exports requested fields", - fields: []string{"assignees", "body", "commentsCount", "labels", "isLocked", "title", "updatedAt"}, + fields: []string{"assignees", "body", "commentsCount", "labels", "isLocked", "repository", "title", "updatedAt"}, issue: Issue{ Assignees: []User{{Login: "test"}}, Body: "body", CommentsCount: 1, Labels: []Label{{Name: "label1"}, {Name: "label2"}}, IsLocked: true, + RepositoryURL: "https://github.com/owner/repo", Title: "title", UpdatedAt: updatedAt, }, - output: `{"assignees":[{"id":"","login":"test","type":""}],"body":"body","commentsCount":1,"isLocked":true,"labels":[{"color":"","description":"","id":"","name":"label1"},{"color":"","description":"","id":"","name":"label2"}],"title":"title","updatedAt":"2021-02-28T12:30:00Z"}`, + output: `{"assignees":[{"id":"","login":"test","type":""}],"body":"body","commentsCount":1,"isLocked":true,"labels":[{"color":"","description":"","id":"","name":"label1"},{"color":"","description":"","id":"","name":"label2"}],"repository":{"name":"repo","nameWithOwner":"owner/repo"},"title":"title","updatedAt":"2021-02-28T12:30:00Z"}`, }, } for _, tt := range tests {