From 60744df04c2b17dbfc168b2eb78296649ad1403b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 3 Apr 2020 02:29:54 +0200 Subject: [PATCH 1/3] use pull.MergedCommitID for merged pulls --- routers/repo/pull.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/routers/repo/pull.go b/routers/repo/pull.go index c29cfb81b22d0..9c39d1bc4b356 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -1162,6 +1162,22 @@ func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) { pr := issue.PullRequest + if pr.HasMerged { + diffType := git.RawDiffType("diff") + if patch { + diffType = git.RawDiffType("patch") + } + if err := git.GetRawDiff( + models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name), + pr.MergedCommitID, + diffType, + ctx.Resp, + ); err != nil { + ctx.ServerError("GetRawDiff", err) + return + } + } + if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch); err != nil { ctx.ServerError("DownloadDiffOrPatch", err) return From d3ccc1b4f52be140a03e87917e6e77a54237d801 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 3 Apr 2020 03:18:13 +0200 Subject: [PATCH 2/3] use Constants --- routers/repo/pull.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 9c39d1bc4b356..309cd5cbcf2bf 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -1163,9 +1163,9 @@ func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) { pr := issue.PullRequest if pr.HasMerged { - diffType := git.RawDiffType("diff") + diffType := git.RawDiffNormal if patch { - diffType = git.RawDiffType("patch") + diffType = git.RawDiffPatch } if err := git.GetRawDiff( models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name), From adb549fec1b0d4de3b5b77f6fe62987ff3860f63 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 3 Apr 2020 03:39:39 +0200 Subject: [PATCH 3/3] Apply suggestions from code review --- routers/repo/pull.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 309cd5cbcf2bf..423c1e188201d 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -1171,11 +1171,12 @@ func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) { models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name), pr.MergedCommitID, diffType, - ctx.Resp, + ctx, ); err != nil { ctx.ServerError("GetRawDiff", err) return } + return } if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch); err != nil {