mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-11 16:05:49 +01:00
(refs #1725) Allow administrators in collaborators to force to merge PR
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user