Skip to content

Commit 4c65a51

Browse files
committed
Unify realisation of DownloadPullDiffOrPatch
1 parent 0a299df commit 4c65a51

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

routers/web/repo/pull.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,29 +1322,16 @@ func DownloadPullPatch(ctx *context.Context) {
13221322

13231323
// DownloadPullDiffOrPatch render a pull's raw diff or patch
13241324
func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
1325-
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
1325+
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
13261326
if err != nil {
1327-
if models.IsErrIssueNotExist(err) {
1328-
ctx.NotFound("GetIssueByIndex", err)
1327+
if models.IsErrPullRequestNotExist(err) {
1328+
ctx.NotFound("GetPullRequestByIndex", err)
13291329
} else {
1330-
ctx.ServerError("GetIssueByIndex", err)
1330+
ctx.ServerError("GetPullRequestByIndex", err)
13311331
}
13321332
return
13331333
}
13341334

1335-
// Return not found if it's not a pull request
1336-
if !issue.IsPull {
1337-
ctx.NotFound("DownloadPullDiff",
1338-
fmt.Errorf("Issue is not a pull request"))
1339-
return
1340-
}
1341-
1342-
if err = issue.LoadPullRequest(); err != nil {
1343-
ctx.ServerError("LoadPullRequest", err)
1344-
return
1345-
}
1346-
1347-
pr := issue.PullRequest
13481335
binary := ctx.FormBool("binary")
13491336

13501337
if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch, binary); err != nil {

0 commit comments

Comments
 (0)