Add "Compare & pull request" button on the top of the repository viewer (#1476)
1 parent 6bd58b0 commit 332a1b4b0b8c3043d8e39f7a3041b12f927f1aa0
@Naoki Takezoe Naoki Takezoe authored on 8 Dec 2017
GitHub committed on 8 Dec 2017
Showing 3 changed files
View
21
src/main/scala/gitbucket/core/controller/PullRequestsController.scala
redirect(s"/${owner}/${name}/pull/${issueId}")
}
})
 
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.
*
* - "owner:branch" to ("owner", "branch")
View
13
src/main/twirl/gitbucket/core/pulls/proposals.scala.html 0 → 100644
@(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 =>
<div class="box-content" style="line-height: 20pt; margin-bottom: 6px; padding: 10px 6px 10px 10px; background-color: #fff9ea">
<strong><i class="menu-icon octicon octicon-git-branch"></i><span class="muted">@branch</span></strong>
<a class="pull-right btn btn-success" style="position: relative; top: -4px;"
href="@helpers.url(repository)/compare/@{parent.owner}:@{parent.repository.defaultBranch}...@{repository.owner}:@{branch}">Compare & pull request</a>
</div>
}
}
View
src/main/twirl/gitbucket/core/repo/files.scala.html