mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Don't delete branch if other PRs with this branch are open (#18164)
fix #18149 Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
		@@ -873,6 +873,17 @@ func MergePullRequest(ctx *context.APIContext) {
 | 
			
		||||
	log.Trace("Pull request merged: %d", pr.ID)
 | 
			
		||||
 | 
			
		||||
	if form.DeleteBranchAfterMerge {
 | 
			
		||||
		// Don't cleanup when there are other PR's that use this branch as head branch.
 | 
			
		||||
		exist, err := models.HasUnmergedPullRequestsByHeadInfo(pr.HeadRepoID, pr.HeadBranch)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			ctx.ServerError("HasUnmergedPullRequestsByHeadInfo", err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		if exist {
 | 
			
		||||
			ctx.Status(http.StatusOK)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var headRepo *git.Repository
 | 
			
		||||
		if ctx.Repo != nil && ctx.Repo.Repository != nil && ctx.Repo.Repository.ID == pr.HeadRepoID && ctx.Repo.GitRepo != nil {
 | 
			
		||||
			headRepo = ctx.Repo.GitRepo
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user