mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	#3466 fix response of pull request form validation error
This commit is contained in:
		| @@ -3,7 +3,7 @@ Gogs - Go Git Service [ |  | ||||||
|  |  | ||||||
| ##### Current tip version: 0.9.78 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) | ##### Current tip version: 0.9.79 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) | ||||||
|  |  | ||||||
| | Web | UI  | Preview  | | | Web | UI  | Preview  | | ||||||
| |:-------------:|:-------:|:-------:| | |:-------------:|:-------:|:-------:| | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							| @@ -17,7 +17,7 @@ import ( | |||||||
| 	"github.com/gogits/gogs/modules/setting" | 	"github.com/gogits/gogs/modules/setting" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const APP_VER = "0.9.78.0815" | const APP_VER = "0.9.79.0815" | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	runtime.GOMAXPROCS(runtime.NumCPU()) | 	runtime.GOMAXPROCS(runtime.NumCPU()) | ||||||
|   | |||||||
| @@ -636,6 +636,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) | |||||||
| 	ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes") | 	ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes") | ||||||
| 	ctx.Data["PageIsComparePull"] = true | 	ctx.Data["PageIsComparePull"] = true | ||||||
| 	ctx.Data["IsDiffCompare"] = true | 	ctx.Data["IsDiffCompare"] = true | ||||||
|  | 	ctx.Data["RequireHighlightJS"] = true | ||||||
| 	renderAttachmentSettings(ctx) | 	renderAttachmentSettings(ctx) | ||||||
|  |  | ||||||
| 	var ( | 	var ( | ||||||
| @@ -648,12 +649,6 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	patch, err := headGitRepo.GetPatch(prInfo.MergeBase, headBranch) |  | ||||||
| 	if err != nil { |  | ||||||
| 		ctx.Handle(500, "GetPatch", err) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	labelIDs, milestoneID, assigneeID := ValidateRepoMetas(ctx, form) | 	labelIDs, milestoneID, assigneeID := ValidateRepoMetas(ctx, form) | ||||||
| 	if ctx.Written() { | 	if ctx.Written() { | ||||||
| 		return | 		return | ||||||
| @@ -664,10 +659,25 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ctx.HasError() { | 	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) | 		ctx.HTML(200, COMPARE_PULL) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	patch, err := headGitRepo.GetPatch(prInfo.MergeBase, headBranch) | ||||||
|  | 	if err != nil { | ||||||
|  | 		ctx.Handle(500, "GetPatch", err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	pullIssue := &models.Issue{ | 	pullIssue := &models.Issue{ | ||||||
| 		RepoID:      repo.ID, | 		RepoID:      repo.ID, | ||||||
| 		Index:       repo.NextIssueIndex(), | 		Index:       repo.NextIssueIndex(), | ||||||
| @@ -690,6 +700,8 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) | |||||||
| 		MergeBase:    prInfo.MergeBase, | 		MergeBase:    prInfo.MergeBase, | ||||||
| 		Type:         models.PULL_REQUEST_GOGS, | 		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 { | 	if err := models.NewPullRequest(repo, pullIssue, labelIDs, attachments, pullRequest, patch); err != nil { | ||||||
| 		ctx.Handle(500, "NewPullRequest", err) | 		ctx.Handle(500, "NewPullRequest", err) | ||||||
| 		return | 		return | ||||||
|   | |||||||
| @@ -1 +1 @@ | |||||||
| 0.9.78.0815 | 0.9.79.0815 | ||||||
| @@ -5,7 +5,7 @@ | |||||||
| 	</div> | 	</div> | ||||||
| 	<div class="ui bottom attached active tab segment" data-tab="write"> | 	<div class="ui bottom attached active tab segment" data-tab="write"> | ||||||
| 		<textarea id="content" class="edit_area" name="content" tabindex="4" data-id="issue-{{.RepoName}}" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.Repo.RepoLink}}"> | 		<textarea id="content" class="edit_area" name="content" tabindex="4" data-id="issue-{{.RepoName}}" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.Repo.RepoLink}}"> | ||||||
| {{if .IssueTemplate}}{{.IssueTemplate}}{{end}}{{if .PullRequestTemplate}}{{.PullRequestTemplate}}{{end}}</textarea> | {{if .IssueTemplate}}{{.IssueTemplate}}{{else if .PullRequestTemplate}}{{.PullRequestTemplate}}{{else}}{{.content}}{{end}}</textarea> | ||||||
| 	</div> | 	</div> | ||||||
| 	<div class="ui bottom attached tab segment markdown" data-tab="preview"> | 	<div class="ui bottom attached tab segment markdown" data-tab="preview"> | ||||||
| 		{{.i18n.Tr "repo.release.loading"}} | 		{{.i18n.Tr "repo.release.loading"}} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user