diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 9520c75..2f913c5 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -502,6 +502,27 @@ } }) + ajaxGet("/:owner/:repository/pulls/proposals")(readableUsersOnly { repository => + (for { + parentUserName <- repository.repository.parentUserName + parentRepoName <- repository.repository.parentRepositoryName + parentRepository <- getRepository(parentUserName, parentRepoName).orElse(Some(repository)) + } yield { + val branches = JGitUtil.getBranches( + owner = repository.owner, + name = repository.name, + defaultBranch = repository.repository.defaultBranch, + origin = repository.repository.originUserName.isEmpty + ) + .filter(x => x.mergeInfo.map(_.ahead).getOrElse(0) > 0 && x.mergeInfo.map(_.behind).getOrElse(0) == 0) + .sortBy(br => (br.mergeInfo.isEmpty, br.commitTime)) + .map(_.name) + .reverse + + html.proposals(branches, parentRepository, repository) + }).getOrElse(NotFound()) + }) + /** * Parses branch identifier and extracts owner and branch name as tuple. * diff --git a/src/main/twirl/gitbucket/core/pulls/proposals.scala.html b/src/main/twirl/gitbucket/core/pulls/proposals.scala.html new file mode 100644 index 0000000..86ccac8 --- /dev/null +++ b/src/main/twirl/gitbucket/core/pulls/proposals.scala.html @@ -0,0 +1,13 @@ +@(branches: Seq[String], + parent: gitbucket.core.service.RepositoryService.RepositoryInfo, + repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) +@import gitbucket.core.view.helpers +@if(branches.nonEmpty){ + @branches.map { branch => +