File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
1919	pull_model "code.gitea.io/gitea/models/pull" 
2020	repo_model "code.gitea.io/gitea/models/repo" 
2121	"code.gitea.io/gitea/models/unit" 
22+ 	unit_model "code.gitea.io/gitea/models/unit" 
2223	user_model "code.gitea.io/gitea/models/user" 
2324	"code.gitea.io/gitea/modules/base" 
2425	"code.gitea.io/gitea/modules/git" 
@@ -1035,8 +1036,17 @@ func MergePullRequest(ctx *context.APIContext) {
10351036	}
10361037	log .Trace ("Pull request merged: %d" , pr .ID )
10371038
1039+ 	prUnit , err  :=  ctx .Repo .Repository .GetUnit (ctx , unit_model .TypePullRequests )
1040+ 	if  err  !=  nil  {
1041+ 		ctx .APIErrorInternal (err )
1042+ 		return 
1043+ 	}
1044+ 
10381045	// for agit flow, we should not delete the agit reference after merge 
1039- 	if  form .DeleteBranchAfterMerge  &&  pr .Flow  ==  issues_model .PullRequestFlowGithub  {
1046+ 	shouldDeleteBranch  :=  (prUnit .PullRequestsConfig ().DefaultDeleteBranchAfterMerge  ||  form .DeleteBranchAfterMerge ) && 
1047+ 		pr .Flow  ==  issues_model .PullRequestFlowGithub 
1048+ 
1049+ 	if  shouldDeleteBranch  {
10401050		// check permission even it has been checked in repo_service.DeleteBranch so that we don't need to 
10411051		// do RetargetChildrenOnMerge 
10421052		if  err  :=  repo_service .CanDeleteBranch (ctx , pr .HeadRepo , pr .HeadBranch , ctx .Doer ); err  ==  nil  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments