diff options
author | Unknwon <u@gogs.io> | 2016-08-15 14:04:44 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-15 14:04:44 -0700 |
commit | 61e27dedf7a02cd01fbf8ad34913c973d057664a (patch) | |
tree | 1895c9e89935efe5738bb5fc9b4cf44b1d6a6631 /routers/repo | |
parent | 94392a7af3d07f79adab195acfb7c1b545f68be9 (diff) | |
download | gitea-61e27dedf7a02cd01fbf8ad34913c973d057664a.tar.gz gitea-61e27dedf7a02cd01fbf8ad34913c973d057664a.zip |
#3466 fix response of pull request form validation error
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/pull.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go index c7fee92906..87bc7bc217 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -636,6 +636,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes") ctx.Data["PageIsComparePull"] = true ctx.Data["IsDiffCompare"] = true + ctx.Data["RequireHighlightJS"] = true renderAttachmentSettings(ctx) var ( @@ -648,12 +649,6 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) return } - patch, err := headGitRepo.GetPatch(prInfo.MergeBase, headBranch) - if err != nil { - ctx.Handle(500, "GetPatch", err) - return - } - labelIDs, milestoneID, assigneeID := ValidateRepoMetas(ctx, form) if ctx.Written() { return @@ -664,10 +659,25 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) } if ctx.HasError() { + auth.AssignForm(form, ctx.Data) + + // This stage is already stop creating new pull request, so it does not matter if it has + // something to compare or not. + PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, prInfo, baseBranch, headBranch) + if ctx.Written() { + return + } + ctx.HTML(200, COMPARE_PULL) return } + patch, err := headGitRepo.GetPatch(prInfo.MergeBase, headBranch) + if err != nil { + ctx.Handle(500, "GetPatch", err) + return + } + pullIssue := &models.Issue{ RepoID: repo.ID, Index: repo.NextIssueIndex(), @@ -690,6 +700,8 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) MergeBase: prInfo.MergeBase, Type: models.PULL_REQUEST_GOGS, } + // FIXME: check error in the case two people send pull request at almost same time, give nice error prompt + // instead of 500. if err := models.NewPullRequest(repo, pullIssue, labelIDs, attachments, pullRequest, patch); err != nil { ctx.Handle(500, "NewPullRequest", err) return |