mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-12 16:35:52 +01:00
(refs #810)Some fix about pull request
This commit is contained in:
@@ -4,8 +4,8 @@ import java.text.SimpleDateFormat
|
||||
import java.util.{Date, Locale, TimeZone}
|
||||
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.model.{CommitState, Repository}
|
||||
import gitbucket.core.plugin.{RenderRequest, PluginRegistry, Renderer}
|
||||
import gitbucket.core.model.CommitState
|
||||
import gitbucket.core.plugin.{RenderRequest, PluginRegistry}
|
||||
import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||
import gitbucket.core.util.{FileUtil, JGitUtil, StringUtil}
|
||||
|
||||
@@ -165,28 +165,10 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
*/
|
||||
def encodeRefName(value: String): String = StringUtil.urlEncode(value).replace("%2F", "/")
|
||||
|
||||
/**
|
||||
* Url encode except '/' and ':'
|
||||
*/
|
||||
def encodeCompareBranch(value: String) =
|
||||
StringUtil.urlEncode(value).replace("%2F", "/").replace("%3A", ":")
|
||||
|
||||
def urlEncode(value: String): String = StringUtil.urlEncode(value)
|
||||
|
||||
def urlEncode(value: Option[String]): String = value.map(urlEncode).getOrElse("")
|
||||
|
||||
/**
|
||||
* The default origin (branch or remote:branch pair) branches are compared to.
|
||||
*
|
||||
* There are two cases: when the repo is a fork and when the repo is not a
|
||||
* fork.
|
||||
*
|
||||
* For a fork, the default ref is parentUserName:defaultBranch.
|
||||
* For a non fork, the default ref is defaultBranch.
|
||||
*/
|
||||
def repositoryDefaultCompareOrigin(repo: Repository): String =
|
||||
repo.parentUserName.map(n => s"$n:${repo.defaultBranch}").getOrElse(repo.defaultBranch)
|
||||
|
||||
/**
|
||||
* Generates the url to the repository.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@(condition: => Boolean)
|
||||
@if(condition){
|
||||
<i class="octicon octicon-check active"></i>
|
||||
<i class="icon-ok"></i>
|
||||
} else {
|
||||
<i class="octicon"></i>
|
||||
<i class="icon-white"></i>
|
||||
}
|
||||
@@ -139,7 +139,7 @@ $(function(){
|
||||
}
|
||||
|
||||
@if(hasWritePermission){
|
||||
function checkConflict(from, to, noConflictHandler, hasConflictHandler){
|
||||
function checkConflict(from, to){
|
||||
$('.check-conflict').show();
|
||||
$.get('@url(repository)/compare/' + from + '...' + to + '/mergecheck',
|
||||
function(data){ $('.check-conflict').html(data); });
|
||||
|
||||
@@ -30,9 +30,17 @@
|
||||
}
|
||||
}.getOrElse{
|
||||
@if(context.loginAccount.isDefined){
|
||||
<a href="@url(repository)/compare/@{encodeCompareBranch(repositoryDefaultCompareOrigin(repository.repository))}...@{encodeCompareBranch(branch.name)}?expand=1" class="btn btn-small">New Pull Request</a>
|
||||
<a href="@url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
|
||||
urlEncode(parent) + ":" + encodeRefName(repository.repository.defaultBranch)
|
||||
}.getOrElse {
|
||||
encodeRefName(repository.repository.defaultBranch)
|
||||
}}...@{encodeRefName(branch.name)}?expand=1" class="btn btn-small">New Pull Request</a>
|
||||
}else{
|
||||
<a href="@url(repository)/compare/@{encodeCompareBranch(repositoryDefaultCompareOrigin(repository.repository))}...@{encodeCompareBranch(branch.name)}" class="btn btn-small">Compare</a>
|
||||
<a href="@url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
|
||||
urlEncode(parent) + ":" + encodeRefName(repository.repository.defaultBranch)
|
||||
}.getOrElse {
|
||||
encodeRefName(repository.repository.defaultBranch)
|
||||
}}...@{encodeRefName(branch.name)}" class="btn btn-small">Compare</a>
|
||||
}
|
||||
}
|
||||
@if(hasWritePermission){
|
||||
|
||||
Reference in New Issue
Block a user