|
|
@ -1307,30 +1307,16 @@ func DownloadPullPatch(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// DownloadPullDiffOrPatch render a pull's raw diff or patch
|
|
|
|
// DownloadPullDiffOrPatch render a pull's raw diff or patch
|
|
|
|
func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
|
|
|
|
func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
|
|
|
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
|
|
|
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if models.IsErrIssueNotExist(err) {
|
|
|
|
if models.IsErrPullRequestNotExist(err) {
|
|
|
|
ctx.NotFound("GetIssueByIndex", err)
|
|
|
|
ctx.NotFound("GetPullRequestByIndex", err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ctx.ServerError("GetIssueByIndex", err)
|
|
|
|
ctx.ServerError("GetPullRequestByIndex", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Return not found if it's not a pull request
|
|
|
|
|
|
|
|
if !issue.IsPull {
|
|
|
|
|
|
|
|
ctx.NotFound("DownloadPullDiff",
|
|
|
|
|
|
|
|
fmt.Errorf("Issue is not a pull request"))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err = issue.LoadPullRequest(); err != nil {
|
|
|
|
|
|
|
|
ctx.ServerError("LoadPullRequest", err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pr := issue.PullRequest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch); err != nil {
|
|
|
|
if err := pull_service.DownloadDiffOrPatch(pr, ctx, patch); err != nil {
|
|
|
|
ctx.ServerError("DownloadDiffOrPatch", err)
|
|
|
|
ctx.ServerError("DownloadDiffOrPatch", err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|