mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Disable merging a WIP Pull request (#4529)
* prevent pull request to be merged when PR is a WIP * add tests * add helper to prepend WIP: in PR title * move default wip prefixes into settings * use configurable WIP prefixes in javascript and default to first one in templates * add documentation * add unit test on pull model Signed-off-by: Julien Tant <julien@craftyx.fr>
This commit is contained in:
		@@ -323,6 +323,12 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.PullReq
 | 
			
		||||
		ctx.ServerError("GetPullRequestInfo", err)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if pull.IsWorkInProgress() {
 | 
			
		||||
		ctx.Data["IsPullWorkInProgress"] = true
 | 
			
		||||
		ctx.Data["WorkInProgressPrefix"] = pull.GetWorkInProgressPrefix()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx.Data["NumCommits"] = prInfo.Commits.Len()
 | 
			
		||||
	ctx.Data["NumFiles"] = prInfo.NumFiles
 | 
			
		||||
	return prInfo
 | 
			
		||||
@@ -516,6 +522,12 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if pr.IsWorkInProgress() {
 | 
			
		||||
		ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_wip"))
 | 
			
		||||
		ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ctx.HasError() {
 | 
			
		||||
		ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
 | 
			
		||||
		ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
 | 
			
		||||
@@ -747,6 +759,7 @@ func CompareAndPullRequest(ctx *context.Context) {
 | 
			
		||||
	ctx.Data["IsDiffCompare"] = true
 | 
			
		||||
	ctx.Data["RequireHighlightJS"] = true
 | 
			
		||||
	ctx.Data["RequireTribute"] = true
 | 
			
		||||
	ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
 | 
			
		||||
	setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
 | 
			
		||||
	renderAttachmentSettings(ctx)
 | 
			
		||||
 | 
			
		||||
@@ -790,6 +803,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm)
 | 
			
		||||
	ctx.Data["PageIsComparePull"] = true
 | 
			
		||||
	ctx.Data["IsDiffCompare"] = true
 | 
			
		||||
	ctx.Data["RequireHighlightJS"] = true
 | 
			
		||||
	ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
 | 
			
		||||
	renderAttachmentSettings(ctx)
 | 
			
		||||
 | 
			
		||||
	var (
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user