From 4d890992c496c5caf77fbd25ef930041da1692e7 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Mon, 7 Sep 2020 17:14:24 +0100 Subject: [PATCH] Use kalafut/m2j to convert markdown to Jira formatting --- go.mod | 1 + go.sum | 2 ++ main.go | 4 +++- main_test.go | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5cfe949..5474ef9 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/tomhjp/gh-action-jira-create go 1.14 require ( + github.com/kalafut/m2j v0.0.0-20200831013012-43edf17eb155 github.com/stretchr/testify v1.6.1 github.com/tomhjp/gh-action-jira v0.1.0 ) diff --git a/go.sum b/go.sum index dc6d1c6..09b2f7f 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/kalafut/m2j v0.0.0-20200831013012-43edf17eb155 h1:eZA4bGAG/36ygQeYyKtKEbuW5C3R80uvoMLQP6bsVvM= +github.com/kalafut/m2j v0.0.0-20200831013012-43edf17eb155/go.mod h1:1tGqsPGFpUsjWhUlxSWTVClcP0spd4hQpA/lRPiAHIc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/main.go b/main.go index 85762ea..41c0b68 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,8 @@ import ( "net/url" "os" + "github.com/kalafut/m2j" + "github.com/tomhjp/gh-action-jira/config" "github.com/tomhjp/gh-action-jira/jira" ) @@ -105,7 +107,7 @@ func constructPayload(project, issueType, summary, description string, extraFiel issueType, }, "summary": summary, - "description": description, + "description": m2j.MDToJira(description), }, } for key, value := range extraFields { diff --git a/main_test.go b/main_test.go index d654e50..8e15ed1 100644 --- a/main_test.go +++ b/main_test.go @@ -8,8 +8,8 @@ import ( ) func TestConstructPayload(t *testing.T) { - const expectedJSON = `{"fields":{"custom_field":[{"name":"foo"}],"description":"The description","foo":"bar","issuetype":{"name":"Bug"},"project":{"key":"FOO"},"summary":"The summary"}}` - reqBody, err := json.Marshal(constructPayload("FOO", "Bug", "The summary", "The description", map[string]interface{}{ + const expectedJSON = `{"fields":{"custom_field":[{"name":"foo"}],"description":"The description with some {{code}}","foo":"bar","issuetype":{"name":"Bug"},"project":{"key":"FOO"},"summary":"The summary"}}` + reqBody, err := json.Marshal(constructPayload("FOO", "Bug", "The summary", "The description with some `code`", map[string]interface{}{ "foo": "bar", "custom_field": []map[string]string{{"name": "foo"}}, }))