(refs #1725) Allow administrators in collaborators to force to merge PR

This commit is contained in:
Naoki Takezoe
2017-10-08 04:17:05 +09:00
parent 5e7afa0f41
commit 37b181c5d0

View File

@@ -1,11 +1,10 @@
package gitbucket.core.service package gitbucket.core.service
import gitbucket.core.model.{ProtectedBranch, ProtectedBranchContext, CommitState} import gitbucket.core.model.{Session => _, _}
import gitbucket.core.plugin.ReceiveHook import gitbucket.core.plugin.ReceiveHook
import gitbucket.core.model.Profile._ import gitbucket.core.model.Profile._
import gitbucket.core.model.Profile.profile.blockingApi._ import gitbucket.core.model.Profile.profile.blockingApi._
import org.eclipse.jgit.transport.{ReceiveCommand, ReceivePack}
import org.eclipse.jgit.transport.{ReceivePack, ReceiveCommand}
trait ProtectedBranchService { trait ProtectedBranchService {
@@ -79,10 +78,19 @@ object ProtectedBranchService {
* Include administrators * Include administrators
* Enforce required status checks for repository administrators. * Enforce required status checks for repository administrators.
*/ */
includeAdministrators: Boolean) extends AccountService with CommitStatusService { includeAdministrators: Boolean) extends AccountService with RepositoryService with CommitStatusService {
def isAdministrator(pusher: String)(implicit session: Session): Boolean = def isAdministrator(pusher: String)(implicit session: Session): Boolean =
pusher == owner || getGroupMembers(owner).exists(gm => gm.userName == pusher && gm.isManager) pusher == owner || getGroupMembers(owner).exists(gm => gm.userName == pusher && gm.isManager) ||
getCollaborators(owner, repository).exists { case (collaborator, isGroup) =>
if(collaborator.role == Role.ADMIN.name){
if(isGroup){
getGroupMembers(collaborator.collaboratorName).exists(gm => gm.userName == pusher)
} else {
collaborator.collaboratorName == pusher
}
} else false
}
/** /**
* Can't be force pushed * Can't be force pushed