diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 35ae255..c3aec88 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -177,7 +177,7 @@ } val hasMergePermission = hasWritePermission(owner, name, context.loginAccount) val branchProtection = getProtectedBranchInfo(owner, name, pullreq.branch) - val state = PullRequestsController.MergeStatus( + val state = PullRequestService.MergeStatus( hasConflict = hasConflict, commitStatues = getCommitStatues(owner, name, pullreq.commitIdTo), branchProtection = branchProtection, @@ -619,31 +619,3 @@ } } } - -object PullRequestsController { - case class MergeStatus( - hasConflict: Boolean, - commitStatues:List[CommitStatus], - branchProtection: ProtectedBrancheService.ProtectedBranchInfo, - branchIsOutOfDate: Boolean, - hasUpdatePermission: Boolean, - needStatusCheck: Boolean, - hasMergePermission: Boolean, - commitIdTo: String){ - - val statuses: List[CommitStatus] = - commitStatues ++ (branchProtection.contexts.toSet -- commitStatues.map(_.context).toSet).map(branchProtection.pendingCommitStatus(_)) - val hasRequiredStatusProblem = needStatusCheck && branchProtection.contexts.exists(context => statuses.find(_.context == context).map(_.state) != Some(CommitState.SUCCESS)) - val hasProblem = hasRequiredStatusProblem || hasConflict || (!statuses.isEmpty && CommitState.combine(statuses.map(_.state).toSet) != CommitState.SUCCESS) - val canUpdate = branchIsOutOfDate && !hasConflict - val canMerge = hasMergePermission && !hasConflict && !hasRequiredStatusProblem - lazy val commitStateSummary:(CommitState, String) = { - val stateMap = statuses.groupBy(_.state) - val state = CommitState.combine(stateMap.keySet) - val summary = stateMap.map{ case (keyState, states) => states.size+" "+keyState.name }.mkString(", ") - state -> summary - } - lazy val statusesAndRequired:List[(CommitStatus, Boolean)] = statuses.map{ s => s -> branchProtection.contexts.exists(_==s.context) } - lazy val isAllSuccess = commitStateSummary._1==CommitState.SUCCESS - } -} diff --git a/src/main/scala/gitbucket/core/service/PullRequestService.scala b/src/main/scala/gitbucket/core/service/PullRequestService.scala index 8fb8521..b383139 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -145,4 +145,29 @@ case class PullRequestCount(userName: String, count: Int) + case class MergeStatus( + hasConflict: Boolean, + commitStatues:List[CommitStatus], + branchProtection: ProtectedBrancheService.ProtectedBranchInfo, + branchIsOutOfDate: Boolean, + hasUpdatePermission: Boolean, + needStatusCheck: Boolean, + hasMergePermission: Boolean, + commitIdTo: String){ + + val statuses: List[CommitStatus] = + commitStatues ++ (branchProtection.contexts.toSet -- commitStatues.map(_.context).toSet).map(branchProtection.pendingCommitStatus(_)) + val hasRequiredStatusProblem = needStatusCheck && branchProtection.contexts.exists(context => statuses.find(_.context == context).map(_.state) != Some(CommitState.SUCCESS)) + val hasProblem = hasRequiredStatusProblem || hasConflict || (!statuses.isEmpty && CommitState.combine(statuses.map(_.state).toSet) != CommitState.SUCCESS) + val canUpdate = branchIsOutOfDate && !hasConflict + val canMerge = hasMergePermission && !hasConflict && !hasRequiredStatusProblem + lazy val commitStateSummary:(CommitState, String) = { + val stateMap = statuses.groupBy(_.state) + val state = CommitState.combine(stateMap.keySet) + val summary = stateMap.map{ case (keyState, states) => states.size+" "+keyState.name }.mkString(", ") + state -> summary + } + lazy val statusesAndRequired:List[(CommitStatus, Boolean)] = statuses.map{ s => s -> branchProtection.contexts.exists(_==s.context) } + lazy val isAllSuccess = commitStateSummary._1==CommitState.SUCCESS + } } diff --git a/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html b/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html index 9817d0a..ca6ed91 100644 --- a/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html +++ b/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html @@ -1,4 +1,4 @@ -@(status: gitbucket.core.controller.PullRequestsController.MergeStatus, +@(status: gitbucket.core.service.PullRequestService.MergeStatus, issue: gitbucket.core.model.Issue, pullreq: gitbucket.core.model.PullRequest, originRepository: gitbucket.core.service.RepositoryService.RepositoryInfo,