mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-10 07:25:50 +01:00
(refs #810)Display Compare (or Pull Request) button for the default branch of the forked repository
This commit is contained in:
@@ -436,10 +436,16 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Displays branches.
|
* Displays branches.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/branches")(referrersOnly { repository =>
|
get("/:owner/:repository/branches")(referrersOnly { repository =>
|
||||||
val branches = JGitUtil.getBranches(repository.owner, repository.name, repository.repository.defaultBranch)
|
val branches = JGitUtil.getBranches(
|
||||||
|
owner = repository.owner,
|
||||||
|
name = repository.name,
|
||||||
|
defaultBranch = repository.repository.defaultBranch,
|
||||||
|
origin = repository.repository.originUserName.isEmpty
|
||||||
|
)
|
||||||
.sortBy(br => (br.mergeInfo.isEmpty, br.commitTime))
|
.sortBy(br => (br.mergeInfo.isEmpty, br.commitTime))
|
||||||
.map(br => br -> getPullRequestByRequestCommit(repository.owner, repository.name, repository.repository.defaultBranch, br.name, br.commitId))
|
.map(br => br -> getPullRequestByRequestCommit(repository.owner, repository.name, repository.repository.defaultBranch, br.name, br.commitId))
|
||||||
.reverse
|
.reverse
|
||||||
|
|
||||||
html.branches(branches, hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
html.branches(branches, hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -791,7 +791,7 @@ object JGitUtil {
|
|||||||
return git.log.add(startCommit).addPath(path).setMaxCount(1).call.iterator.next
|
return git.log.add(startCommit).addPath(path).setMaxCount(1).call.iterator.next
|
||||||
}
|
}
|
||||||
|
|
||||||
def getBranches(owner: String, name: String, defaultBranch: String): Seq[BranchInfo] = {
|
def getBranches(owner: String, name: String, defaultBranch: String, origin: Boolean): Seq[BranchInfo] = {
|
||||||
using(Git.open(getRepositoryDir(owner, name))){ git =>
|
using(Git.open(getRepositoryDir(owner, name))){ git =>
|
||||||
val repo = git.getRepository
|
val repo = git.getRepository
|
||||||
val defaultObject = if (repo.getAllRefs.keySet().contains(defaultBranch)) {
|
val defaultObject = if (repo.getAllRefs.keySet().contains(defaultBranch)) {
|
||||||
@@ -813,7 +813,7 @@ object JGitUtil {
|
|||||||
val when = branchCommit.getCommitterIdent.getWhen
|
val when = branchCommit.getCommitterIdent.getWhen
|
||||||
val committer = branchCommit.getCommitterIdent.getName
|
val committer = branchCommit.getCommitterIdent.getName
|
||||||
val committerEmail = branchCommit.getCommitterIdent.getEmailAddress
|
val committerEmail = branchCommit.getCommitterIdent.getEmailAddress
|
||||||
val mergeInfo = if(branchName==defaultBranch){
|
val mergeInfo = if(origin && branchName == defaultBranch){
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
walk.reset()
|
walk.reset()
|
||||||
|
|||||||
Reference in New Issue
Block a user