mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Allow repo admin to merge PR regardless of review status (#9611)
* Allow repo admin to merge even if review is not ok.
This commit is contained in:
		
				
					committed by
					
						
						techknowlogick
					
				
			
			
				
	
			
			
			
						parent
						
							4d06d10dba
						
					
				
				
					commit
					32fb813133
				
			@@ -93,8 +93,8 @@ func (protectBranch *ProtectedBranch) CanUserPush(userID int64) bool {
 | 
			
		||||
	return in
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CanUserMerge returns if some user could merge a pull request to this protected branch
 | 
			
		||||
func (protectBranch *ProtectedBranch) CanUserMerge(userID int64) bool {
 | 
			
		||||
// IsUserMergeWhitelisted checks if some user is whitelisted to merge to this branch
 | 
			
		||||
func (protectBranch *ProtectedBranch) IsUserMergeWhitelisted(userID int64) bool {
 | 
			
		||||
	if !protectBranch.EnableMergeWhitelist {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
@@ -348,27 +348,6 @@ func (repo *Repository) IsProtectedBranchForPush(branchName string, doer *User)
 | 
			
		||||
	return false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsProtectedBranchForMerging checks if branch is protected for merging
 | 
			
		||||
func (repo *Repository) IsProtectedBranchForMerging(pr *PullRequest, branchName string, doer *User) (bool, error) {
 | 
			
		||||
	if doer == nil {
 | 
			
		||||
		return true, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protectedBranch := &ProtectedBranch{
 | 
			
		||||
		RepoID:     repo.ID,
 | 
			
		||||
		BranchName: branchName,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	has, err := x.Get(protectedBranch)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return true, err
 | 
			
		||||
	} else if has {
 | 
			
		||||
		return !protectedBranch.CanUserMerge(doer.ID) || !protectedBranch.HasEnoughApprovals(pr) || protectedBranch.MergeBlockedByRejectedReview(pr), nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// updateApprovalWhitelist checks whether the user whitelist changed and returns a whitelist with
 | 
			
		||||
// the users from newWhitelist which have explicit read or write access to the repo.
 | 
			
		||||
func updateApprovalWhitelist(repo *Repository, currentWhitelist, newWhitelist []int64) (whitelist []int64, err error) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user