From 332a1b4b0b8c3043d8e39f7a3041b12f927f1aa0 Mon Sep 17 00:00:00 2001
From: Naoki Takezoe
Date: Sat, 9 Dec 2017 04:52:21 +0900
Subject: [PATCH] Add "Compare & pull request" button on the top of the
repository viewer (#1476)
---
.../controller/PullRequestsController.scala | 21 ++++++++++
.../gitbucket/core/pulls/proposals.scala.html | 13 +++++++
.../gitbucket/core/repo/files.scala.html | 39 ++++++++++++-------
3 files changed, 59 insertions(+), 14 deletions(-)
create mode 100644 src/main/twirl/gitbucket/core/pulls/proposals.scala.html
diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala
index 9520c7501..2f913c5ca 100644
--- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala
+++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala
@@ -502,6 +502,27 @@ trait PullRequestsControllerBase extends ControllerBase {
}
})
+ 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 000000000..86ccac8c9
--- /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 =>
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/twirl/gitbucket/core/repo/files.scala.html b/src/main/twirl/gitbucket/core/repo/files.scala.html
index f3e64db31..fb1c4d897 100644
--- a/src/main/twirl/gitbucket/core/repo/files.scala.html
+++ b/src/main/twirl/gitbucket/core/repo/files.scala.html
@@ -29,6 +29,7 @@
}
}
+
@@ -204,19 +205,29 @@
}
}