Merge branch 'beraboris-implement-668'

This commit is contained in:
Naoki Takezoe
2015-07-28 11:13:51 +09:00
5 changed files with 65 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ import java.util.{Date, Locale, TimeZone}
import gitbucket.core.controller.Context
import gitbucket.core.model.CommitState
import gitbucket.core.plugin.{RenderRequest, PluginRegistry, Renderer}
import gitbucket.core.plugin.{RenderRequest, PluginRegistry}
import gitbucket.core.service.{RepositoryService, RequestCache}
import gitbucket.core.util.{FileUtil, JGitUtil, StringUtil}

View File

@@ -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>
}

View File

@@ -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); });

View File

@@ -30,9 +30,17 @@
}
}.getOrElse{
@if(context.loginAccount.isDefined){
<a href="@url(repository)/compare/@{encodeRefName(repository.repository.defaultBranch)}...@{encodeRefName(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/@{encodeRefName(repository.repository.defaultBranch)}...@{encodeRefName(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){

View File

@@ -0,0 +1,51 @@
package gitbucket.core.view
import org.specs2.mutable._
import gitbucket.core.model.Repository
import java.util.Date
class HelpersSpec extends Specification {
def repository(defaultBranch: String, parentUserName: Option[String]) =
Repository(
userName = "some-user",
repositoryName = "some-repo",
isPrivate = false,
description = None,
defaultBranch = defaultBranch,
parentUserName = parentUserName,
parentRepositoryName = Some("some-repo"),
registeredDate = new Date(),
updatedDate = new Date(),
lastActivityDate = new Date(),
originUserName = Some("some-other-user"),
originRepositoryName = Some("some-repo")
)
"repositoryDefaultCompareOrigin" should {
"return default branch when not fork" in {
val repo = repository("master", None)
helpers.repositoryDefaultCompareOrigin(repo) mustEqual "master"
}
"return [upstream]:[branch] when a fork" in {
val repo = repository("some-branch", Some("parent-user"))
helpers.repositoryDefaultCompareOrigin(repo) mustEqual "parent-user:some-branch"
}
}
"encodeCompareBranch" should {
"not uri encode /" in {
helpers.encodeCompareBranch("foo/bar#baz") mustEqual "foo/bar%23baz"
}
"not uri encode :" in {
helpers.encodeCompareBranch("foo:bar#baz") mustEqual "foo:bar%23baz"
}
"uri encode special characters" in {
helpers.encodeCompareBranch("!#$&'()+,;=?@[]") mustEqual "%21%23%24%26%27%28%29%2B%2C%3B%3D%3F%40%5B%5D"
}
}
}