From 313638be36aade4a038197389eddf199064adf43 Mon Sep 17 00:00:00 2001 From: mjdouble Date: Fri, 24 Apr 2020 12:51:20 -0400 Subject: [PATCH] add PR title to metadata (#172) * add PR title to metadata * add title meta to tests * fixing tests Co-authored-by: itsdalmo --- in.go | 1 + in_test.go | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/in.go b/in.go index 08ab13e1..be3f6d2d 100644 --- a/in.go +++ b/in.go @@ -73,6 +73,7 @@ func Get(request GetRequest, github Github, git Git, outputDir string) (*GetResp metadata.Add("message", pull.Tip.Message) metadata.Add("author", pull.Tip.Author.User.Login) metadata.Add("author_email", pull.Tip.Author.Email) + metadata.Add("title", pull.Title) // Write version and metadata for reuse in PUT path := filepath.Join(outputDir, ".git", "resource") diff --git a/in_test.go b/in_test.go index 0de26dbf..306cd5dd 100644 --- a/in_test.go +++ b/in_test.go @@ -42,7 +42,7 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{}, pullRequest: createTestPR(1, "master", false, false, 0, nil), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"}]`, + metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"title","value":"pr1 title"}]`, }, { description: "get supports unlocking with git crypt", @@ -59,7 +59,7 @@ func TestGet(t *testing.T) { parameters: resource.GetParameters{}, pullRequest: createTestPR(1, "master", false, false, 0, nil), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"}]`, + metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"title","value":"pr1 title"}]`, }, { description: "get supports rebasing", @@ -77,7 +77,7 @@ func TestGet(t *testing.T) { }, pullRequest: createTestPR(1, "master", false, false, 0, nil), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"}]`, + metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"title","value":"pr1 title"}]`, }, { description: "get supports checkout", @@ -95,7 +95,7 @@ func TestGet(t *testing.T) { }, pullRequest: createTestPR(1, "master", false, false, 0, nil), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"}]`, + metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"title","value":"pr1 title"}]`, }, { description: "get supports git_depth", @@ -113,7 +113,7 @@ func TestGet(t *testing.T) { }, pullRequest: createTestPR(1, "master", false, false, 0, nil), versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"}]`, + metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"title","value":"pr1 title"}]`, }, { description: "get supports list_changed_files", @@ -139,7 +139,7 @@ func TestGet(t *testing.T) { }, }, versionString: `{"pr":"pr1","commit":"commit1","committed":"0001-01-01T00:00:00Z"}`, - metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"}]`, + metadataString: `[{"name":"pr","value":"1"},{"name":"url","value":"pr1 url"},{"name":"head_name","value":"pr1"},{"name":"head_sha","value":"oid1"},{"name":"base_name","value":"master"},{"name":"base_sha","value":"sha"},{"name":"message","value":"commit message1"},{"name":"author","value":"login1"},{"name":"author_email","value":"user@example.com"},{"name":"title","value":"pr1 title"}]`, filesString: "README.md\nOther.md\n", }, } @@ -184,6 +184,7 @@ func TestGet(t *testing.T) { "message": "commit message1", "author": "login1", "author_email": "user@example.com", + "title": "pr1 title", } for filename, expected := range files {