From 9d3cbb497206224567d9f4e044af2754f567e988 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 18:07:43 +0200 Subject: [PATCH 01/10] Add API to get commit diff/patch --- routers/api/v1/api.go | 4 ++ routers/api/v1/repo/commits.go | 78 ++++++++++++++++++++++++++++++ templates/swagger/v1_json.tmpl | 86 ++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index d859642c42a1..7f352b48bee2 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -937,6 +937,10 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route { m.Group("/git", func() { m.Group("/commits", func() { m.Get("/{sha}", repo.GetSingleCommit) + m.Get("/{sha}.diff", + repo.DownloadCommitDiff) + m.Get("/{sha}.patch", + repo.DownloadCommitPatch) }) m.Get("/refs", repo.GetGitAllRefs) m.Get("/refs/*", repo.GetGitRefs) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index 975b9cab2a9c..b2b5fc424643 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -213,3 +213,81 @@ func GetAllCommits(ctx *context.APIContext) { ctx.JSON(http.StatusOK, &apiCommits) } + +func DownloadCommitDiff(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.diff repository repoDownloadCommitDiff + // --- + // summary: Get a commit diff + // produces: + // - text/plain + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: sha + // in: path + // description: SHA of the commit to get + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/string" + // "404": + // "$ref": "#/responses/notFound" + DownloadCommitDiffOrPatch(ctx, "diff") +} + +func DownloadCommitPatch(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.patch repository repoDownloadCommitPatch + // --- + // summary: Get a commit patch + // produces: + // - text/plain + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: sha + // in: path + // description: SHA of the commit to get + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/string" + // "404": + // "$ref": "#/responses/notFound" + DownloadCommitDiffOrPatch(ctx, "patch") +} + +func DownloadCommitDiffOrPatch(ctx *context.APIContext, diffType string) { + var repoPath string + repoPath = models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) + if err := git.GetRawDiff( + repoPath, + ctx.Params(":sha"), + git.RawDiffType(diffType), + ctx.Resp, + ); err != nil { + if git.IsErrNotExist(err) { + ctx.NotFound(ctx.Params(":sha")) + return + } + ctx.Error(http.StatusInternalServerError, "DownloadCommitDiffOrPatch", err) + return + } +} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 69081777dc74..23a6645e0cb5 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3581,6 +3581,92 @@ } } }, + "/repos/{owner}/{repo}/git/commits/{sha}.diff": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit diff", + "operationId": "repoDownloadCommitDiff", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "SHA of the commit to get", + "name": "sha", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/string" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, + "/repos/{owner}/{repo}/git/commits/{sha}.patch": { + "get": { + "produces": [ + "text/plain" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit patch", + "operationId": "repoDownloadCommitPatch", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "SHA of the commit to get", + "name": "sha", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/string" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/repos/{owner}/{repo}/git/notes/{sha}": { "get": { "produces": [ From ea7d8b61a9e08b34cf057d52eb2caf363e8b15ee Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 18:33:41 +0200 Subject: [PATCH 02/10] Fix lint --- routers/api/v1/repo/commits.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index b2b5fc424643..f7f8f32a91ba 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -275,8 +275,7 @@ func DownloadCommitPatch(ctx *context.APIContext) { } func DownloadCommitDiffOrPatch(ctx *context.APIContext, diffType string) { - var repoPath string - repoPath = models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) + repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if err := git.GetRawDiff( repoPath, ctx.Params(":sha"), From b31c8317f788aa52c415c50bdf82b743ea60b734 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 18:37:46 +0200 Subject: [PATCH 03/10] Fix lint --- routers/api/v1/repo/commits.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index f7f8f32a91ba..d8d740fefb7b 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -214,6 +214,7 @@ func GetAllCommits(ctx *context.APIContext) { ctx.JSON(http.StatusOK, &apiCommits) } +// DownloadCommitDiff render a commit's raw diff func DownloadCommitDiff(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.diff repository repoDownloadCommitDiff // --- @@ -244,6 +245,7 @@ func DownloadCommitDiff(ctx *context.APIContext) { DownloadCommitDiffOrPatch(ctx, "diff") } +// DownloadCommitPatch render a commit's raw patch func DownloadCommitPatch(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.patch repository repoDownloadCommitPatch // --- @@ -274,6 +276,7 @@ func DownloadCommitPatch(ctx *context.APIContext) { DownloadCommitDiffOrPatch(ctx, "patch") } +// DownloadCommitDiffOrPatch render a commit's raw diff func DownloadCommitDiffOrPatch(ctx *context.APIContext, diffType string) { repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if err := git.GetRawDiff( From 7e8d5cf1e0a0e5c49802e626fa5f6ecfb710ad08 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 19:13:21 +0200 Subject: [PATCH 04/10] Merge endpoints --- routers/api/v1/api.go | 5 +--- routers/api/v1/repo/commits.go | 52 +++++++--------------------------- templates/swagger/v1_json.tmpl | 49 ++------------------------------ 3 files changed, 15 insertions(+), 91 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 7f352b48bee2..90189701c01a 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -937,10 +937,7 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route { m.Group("/git", func() { m.Group("/commits", func() { m.Get("/{sha}", repo.GetSingleCommit) - m.Get("/{sha}.diff", - repo.DownloadCommitDiff) - m.Get("/{sha}.patch", - repo.DownloadCommitPatch) + m.Get("/{sha}.{diffType:diff|patch}", repo.DownloadCommitDiffOrPatch) }) m.Get("/refs", repo.GetGitAllRefs) m.Get("/refs/*", repo.GetGitRefs) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index d8d740fefb7b..1a804dafe92e 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -214,11 +214,11 @@ func GetAllCommits(ctx *context.APIContext) { ctx.JSON(http.StatusOK, &apiCommits) } -// DownloadCommitDiff render a commit's raw diff -func DownloadCommitDiff(ctx *context.APIContext) { - // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.diff repository repoDownloadCommitDiff +// DownloadCommitDiffOrPatch render a commit's raw diff or patch +func DownloadCommitDiffOrPatch(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.{diffType} repository repoDownloadCommitDiffOrPatch // --- - // summary: Get a commit diff + // summary: Get a commit's diff or patch // produces: // - text/plain // parameters: @@ -237,52 +237,22 @@ func DownloadCommitDiff(ctx *context.APIContext) { // description: SHA of the commit to get // type: string // required: true + // - name: diffType + // in: path + // description: whether the output is diff or patch + // type: string + // enum: [diff, patch] + // required: true // responses: // "200": // "$ref": "#/responses/string" // "404": // "$ref": "#/responses/notFound" - DownloadCommitDiffOrPatch(ctx, "diff") -} - -// DownloadCommitPatch render a commit's raw patch -func DownloadCommitPatch(ctx *context.APIContext) { - // swagger:operation GET /repos/{owner}/{repo}/git/commits/{sha}.patch repository repoDownloadCommitPatch - // --- - // summary: Get a commit patch - // produces: - // - text/plain - // parameters: - // - name: owner - // in: path - // description: owner of the repo - // type: string - // required: true - // - name: repo - // in: path - // description: name of the repo - // type: string - // required: true - // - name: sha - // in: path - // description: SHA of the commit to get - // type: string - // required: true - // responses: - // "200": - // "$ref": "#/responses/string" - // "404": - // "$ref": "#/responses/notFound" - DownloadCommitDiffOrPatch(ctx, "patch") -} - -// DownloadCommitDiffOrPatch render a commit's raw diff -func DownloadCommitDiffOrPatch(ctx *context.APIContext, diffType string) { repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if err := git.GetRawDiff( repoPath, ctx.Params(":sha"), - git.RawDiffType(diffType), + git.RawDiffType(ctx.Params(":type")), ctx.Resp, ); err != nil { if git.IsErrNotExist(err) { diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 23a6645e0cb5..dc9783e12d2b 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3581,7 +3581,7 @@ } } }, - "/repos/{owner}/{repo}/git/commits/{sha}.diff": { + "/repos/{owner}/{repo}/git/commits/{sha}.{diffType}": { "get": { "produces": [ "text/plain" @@ -3589,51 +3589,8 @@ "tags": [ "repository" ], - "summary": "Get a commit diff", - "operationId": "repoDownloadCommitDiff", - "parameters": [ - { - "type": "string", - "description": "owner of the repo", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name of the repo", - "name": "repo", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "SHA of the commit to get", - "name": "sha", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "$ref": "#/responses/string" - }, - "404": { - "$ref": "#/responses/notFound" - } - } - } - }, - "/repos/{owner}/{repo}/git/commits/{sha}.patch": { - "get": { - "produces": [ - "text/plain" - ], - "tags": [ - "repository" - ], - "summary": "Get a commit patch", - "operationId": "repoDownloadCommitPatch", + "summary": "Get a commit's diff or patch", + "operationId": "repoDownloadCommitDiffOrPatch", "parameters": [ { "type": "string", From 8bb41e3437b938124f8a270034ba405e41cbdd5e Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 19:17:06 +0200 Subject: [PATCH 05/10] Fix parameter --- routers/api/v1/repo/commits.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index 1a804dafe92e..e5459ed79334 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -252,7 +252,7 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) { if err := git.GetRawDiff( repoPath, ctx.Params(":sha"), - git.RawDiffType(ctx.Params(":type")), + git.RawDiffType(ctx.Params(":diffType")), ctx.Resp, ); err != nil { if git.IsErrNotExist(err) { From 1b04cbbec563f33a65ff88ad12cb0958c4a56bdd Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Sep 2021 19:34:13 +0200 Subject: [PATCH 06/10] tab2space --- routers/api/v1/repo/commits.go | 10 +++++----- templates/swagger/v1_json.tmpl | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index e5459ed79334..639100757bdd 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -238,11 +238,11 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) { // type: string // required: true // - name: diffType - // in: path - // description: whether the output is diff or patch - // type: string - // enum: [diff, patch] - // required: true + // in: path + // description: whether the output is diff or patch + // type: string + // enum: [diff, patch] + // required: true // responses: // "200": // "$ref": "#/responses/string" diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index dc9783e12d2b..77c89aea3af9 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3612,6 +3612,17 @@ "name": "sha", "in": "path", "required": true + }, + { + "enum": [ + "diff", + "patch" + ], + "type": "string", + "description": "whether the output is diff or patch", + "name": "diffType", + "in": "path", + "required": true } ], "responses": { From 67ebe5070d63b41e825f609446598459f6b46b09 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 19:53:07 +0200 Subject: [PATCH 07/10] Add integration test --- integrations/api_repo_git_commits_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/integrations/api_repo_git_commits_test.go b/integrations/api_repo_git_commits_test.go index 19dab433d468..8cb4874edee0 100644 --- a/integrations/api_repo_git_commits_test.go +++ b/integrations/api_repo_git_commits_test.go @@ -109,3 +109,19 @@ func TestAPIReposGitCommitListDifferentBranch(t *testing.T) { assert.Equal(t, "f27c2b2b03dcab38beaf89b0ab4ff61f6de63441", apiData[0].CommitMeta.SHA) compareCommitFiles(t, []string{"readme.md"}, apiData[0].Files) } + +func TestDownloadCommitDiffOrPatch(t *testing.T) { + defer prepareTestEnv(t)() + user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + // Login as User2. + session := loginUser(t, user.Name) + token := getTokenForLoggedInUser(t, session) + + // Test getting diff + req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff?token="+token, user.Name) + resp := session.MakeRequest(t, req, http.StatusOK) + + // Test getting patch + req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch?token="+token, user.Name) + resp := session.MakeRequest(t, req, http.StatusOK) +} From c5c0c72ae7f295a3ee08e1eba451a11ea4c98e10 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Sep 2021 19:59:36 +0200 Subject: [PATCH 08/10] Fix integration test --- integrations/api_repo_git_commits_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integrations/api_repo_git_commits_test.go b/integrations/api_repo_git_commits_test.go index 8cb4874edee0..5325a78fbbcf 100644 --- a/integrations/api_repo_git_commits_test.go +++ b/integrations/api_repo_git_commits_test.go @@ -118,10 +118,10 @@ func TestDownloadCommitDiffOrPatch(t *testing.T) { token := getTokenForLoggedInUser(t, session) // Test getting diff - req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff?token="+token, user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + reqDiff := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff?token="+token, user.Name) + session.MakeRequest(t, reqDiff, http.StatusOK) // Test getting patch - req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch?token="+token, user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + reqPatch := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch?token="+token, user.Name) + session.MakeRequest(t, reqPatch, http.StatusOK) } From e1ae4fbe8c28c72746390b5191eb64e8c0cd3c57 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 20 Sep 2021 16:35:47 +0200 Subject: [PATCH 09/10] extend test --- integrations/api_repo_git_commits_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integrations/api_repo_git_commits_test.go b/integrations/api_repo_git_commits_test.go index 5325a78fbbcf..b4eb5d468a72 100644 --- a/integrations/api_repo_git_commits_test.go +++ b/integrations/api_repo_git_commits_test.go @@ -119,9 +119,11 @@ func TestDownloadCommitDiffOrPatch(t *testing.T) { // Test getting diff reqDiff := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff?token="+token, user.Name) - session.MakeRequest(t, reqDiff, http.StatusOK) + resp := session.MakeRequest(t, reqDiff, http.StatusOK) + assert.EqualValues(t, "commit f27c2b2b03dcab38beaf89b0ab4ff61f6de63441\nAuthor: User2 \nDate: Sun Aug 6 19:55:01 2017 +0200\n\n good signed commit\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", string(resp.Body.Bytes())) // Test getting patch reqPatch := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch?token="+token, user.Name) - session.MakeRequest(t, reqPatch, http.StatusOK) + resp = session.MakeRequest(t, reqPatch, http.StatusOK) + assert.EqualValues(t, "From f27c2b2b03dcab38beaf89b0ab4ff61f6de63441 Mon Sep 17 00:00:00 2001\nFrom: User2 \nDate: Sun, 6 Aug 2017 19:55:01 +0200\nSubject: [PATCH] good signed commit\n\n---\n readme.md | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 readme.md\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", string(resp.Body.Bytes())) } From 283adfc7c50c24a68e9407e28b587c2a9f350706 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 20 Sep 2021 16:49:44 +0200 Subject: [PATCH 10/10] fix lint issue --- integrations/api_repo_git_commits_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/integrations/api_repo_git_commits_test.go b/integrations/api_repo_git_commits_test.go index b4eb5d468a72..314416d2646e 100644 --- a/integrations/api_repo_git_commits_test.go +++ b/integrations/api_repo_git_commits_test.go @@ -120,10 +120,15 @@ func TestDownloadCommitDiffOrPatch(t *testing.T) { // Test getting diff reqDiff := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff?token="+token, user.Name) resp := session.MakeRequest(t, reqDiff, http.StatusOK) - assert.EqualValues(t, "commit f27c2b2b03dcab38beaf89b0ab4ff61f6de63441\nAuthor: User2 \nDate: Sun Aug 6 19:55:01 2017 +0200\n\n good signed commit\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", string(resp.Body.Bytes())) + assert.EqualValues(t, + "commit f27c2b2b03dcab38beaf89b0ab4ff61f6de63441\nAuthor: User2 \nDate: Sun Aug 6 19:55:01 2017 +0200\n\n good signed commit\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", + resp.Body.String()) // Test getting patch reqPatch := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch?token="+token, user.Name) resp = session.MakeRequest(t, reqPatch, http.StatusOK) - assert.EqualValues(t, "From f27c2b2b03dcab38beaf89b0ab4ff61f6de63441 Mon Sep 17 00:00:00 2001\nFrom: User2 \nDate: Sun, 6 Aug 2017 19:55:01 +0200\nSubject: [PATCH] good signed commit\n\n---\n readme.md | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 readme.md\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", string(resp.Body.Bytes())) + assert.EqualValues(t, + "From f27c2b2b03dcab38beaf89b0ab4ff61f6de63441 Mon Sep 17 00:00:00 2001\nFrom: User2 \nDate: Sun, 6 Aug 2017 19:55:01 +0200\nSubject: [PATCH] good signed commit\n\n---\n readme.md | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 readme.md\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", + resp.Body.String()) + }