diff --git a/src/main/scala/gitbucket/core/controller/ControllerBase.scala b/src/main/scala/gitbucket/core/controller/ControllerBase.scala index 38d7ad9..c8dabcc 100644 --- a/src/main/scala/gitbucket/core/controller/ControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/ControllerBase.scala @@ -3,6 +3,7 @@ import gitbucket.core.api.ApiError import gitbucket.core.model.Account import gitbucket.core.service.{AccountService, SystemSettingsService} +import gitbucket.core.service.RepositoryService.{RepositoryInfo, RepositoryUrls} import gitbucket.core.util.ControlUtil._ import gitbucket.core.util.Directory._ import gitbucket.core.util.Implicits._ @@ -184,7 +185,8 @@ val currentPath = request.getRequestURI.substring(request.getContextPath.length) val baseUrl = settings.baseUrl(request) val host = new java.net.URL(baseUrl).getHost - val repoBase = RepoBase(baseUrl, settings.sshAddress) + val urls = (repositoryInfo:RepositoryInfo) => new RepositoryUrls(baseUrl, settings.sshAddress, repositoryInfo.owner, repositoryInfo.name) + val wikiUrls = (repositoryInfo:RepositoryInfo) => new RepositoryUrls(baseUrl, settings.sshAddress, repositoryInfo.owner, repositoryInfo.name + ".wiki") val platform = request.getHeader("User-Agent") match { case null => null case agent if agent.contains("Mac") => "mac" diff --git a/src/main/scala/gitbucket/core/service/RepositoryService.scala b/src/main/scala/gitbucket/core/service/RepositoryService.scala index edcbb3a..2544876 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryService.scala @@ -1,8 +1,9 @@ package gitbucket.core.service +import gitbucket.core.service.SystemSettingsService.SshAddress import gitbucket.core.model.{Collaborator, Repository, Account} import gitbucket.core.model.Profile._ -import gitbucket.core.util.{JGitUtil, RepoBase} +import gitbucket.core.util.JGitUtil import profile.simple._ trait RepositoryService { self: AccountService => @@ -391,8 +392,6 @@ issueCount: Int, pullCount: Int, commitCount: Int, forkedCount: Int, branchList: Seq[String], tags: Seq[JGitUtil.TagInfo], managers: Seq[String]) { - def urls(repoBase:RepoBase):RepositoryUrls = new RepositoryUrls(repoBase, owner, name) - /** * Creates instance with issue count and pull request count. */ @@ -412,13 +411,13 @@ repo.commitCount, forkedCount, repo.branchList, repo.tags, managers) } - final class RepositoryUrls(repoBase:RepoBase, owner:String, name:String) { + final class RepositoryUrls(baseUrl:String, sshAddress:Option[SshAddress], owner:String, name:String) { def httpUrl:String = - s"${repoBase.baseUrl}/git/${owner}/${name}.git" + s"${baseUrl}/git/${owner}/${name}.git" // BETTER make this return an Option and use it in the gui def sshUrl(userName: String):String = - repoBase.sshAddress.fold("")(adr => s"ssh://${userName}@${adr.host}:${adr.port}/${owner}/${name}.git") + sshAddress.fold("")(adr => s"ssh://${userName}@${adr.host}:${adr.port}/${owner}/${name}.git") def sshOpenRepoUrl(platform: String, userName: String) = openRepoUrl(platform, sshUrl(userName)) diff --git a/src/main/scala/gitbucket/core/service/WikiService.scala b/src/main/scala/gitbucket/core/service/WikiService.scala index 3c00485..f1d7749 100644 --- a/src/main/scala/gitbucket/core/service/WikiService.scala +++ b/src/main/scala/gitbucket/core/service/WikiService.scala @@ -1,6 +1,7 @@ package gitbucket.core.service import java.util.Date +import gitbucket.core.service.SystemSettingsService.SshAddress import gitbucket.core.model.Account import gitbucket.core.util._ import gitbucket.core.util.ControlUtil._ @@ -38,9 +39,6 @@ * @param date the commit date */ case class WikiPageHistoryInfo(name: String, committer: String, message: String, date: Date) - - def urls(repoBase:RepoBase, repository: RepositoryInfo):RepositoryUrls = - new RepositoryUrls(repoBase, repository.owner, repository.name + ".wiki") } trait WikiService { diff --git a/src/main/scala/gitbucket/core/util/RepoBase.scala b/src/main/scala/gitbucket/core/util/RepoBase.scala deleted file mode 100644 index 6fc9b4b..0000000 --- a/src/main/scala/gitbucket/core/util/RepoBase.scala +++ /dev/null @@ -1,5 +0,0 @@ -package gitbucket.core.util - -import gitbucket.core.service.SystemSettingsService.SshAddress - -case class RepoBase(baseUrl:String, sshAddress:Option[SshAddress]) diff --git a/src/main/scala/gitbucket/core/view/Markdown.scala b/src/main/scala/gitbucket/core/view/Markdown.scala index b31eef8..449a47b 100644 --- a/src/main/scala/gitbucket/core/view/Markdown.scala +++ b/src/main/scala/gitbucket/core/view/Markdown.scala @@ -60,7 +60,7 @@ pages: List[String]) (implicit val context: Context) extends Renderer(options) with LinkConverter with RequestCache { - private val repositoryUrls = repository.urls(context.repoBase) + private val repositoryUrls = context.urls(repository) override def heading(text: String, level: Int, raw: String): String = { val id = generateAnchorName(text) diff --git a/src/main/twirl/gitbucket/core/main.scala.html b/src/main/twirl/gitbucket/core/main.scala.html index 2b179b4..69fcfdc 100644 --- a/src/main/twirl/gitbucket/core/main.scala.html +++ b/src/main/twirl/gitbucket/core/main.scala.html @@ -37,7 +37,7 @@ @repository.map { repository => @if(!repository.repository.isPrivate){ - + } } diff --git a/src/main/twirl/gitbucket/core/menu.scala.html b/src/main/twirl/gitbucket/core/menu.scala.html index 828769e..560d16e 100644 --- a/src/main/twirl/gitbucket/core/menu.scala.html +++ b/src/main/twirl/gitbucket/core/menu.scala.html @@ -80,8 +80,8 @@
HTTP clone URL
- @helper.html.copy("repository-url-copy", repository.urls(repoBase).httpUrl){ - + @helper.html.copy("repository-url-copy", context.urls(repository).httpUrl){ + } @if(settings.ssh && loginAccount.isDefined){
@@ -91,7 +91,7 @@ @id.map { id => @if(context.platform != "linux" && context.platform != null){
-   Clone in Desktop +   Clone in Desktop
}
@@ -184,15 +184,15 @@ @if(settings.ssh && loginAccount.isDefined){ $('#repository-url-http').click(function(){ $('#repository-url-proto').text('HTTP'); - $('#repository-url').val('@repository.urls(repoBase).httpUrl'); - $('#repository-clone-url').attr('href', '@repository.urls(repoBase).httpOpenRepoUrl(context.platform)') + $('#repository-url').val('@context.urls(repository).httpUrl'); + $('#repository-clone-url').attr('href', '@context.urls(repository).httpOpenRepoUrl(context.platform)') $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); }); $('#repository-url-ssh').click(function(){ $('#repository-url-proto').text('SSH'); - $('#repository-url').val('@repository.urls(repoBase).sshUrl(loginAccount.get.userName)'); - $('#repository-clone-url').attr('href', '@repository.urls(repoBase).sshOpenRepoUrl(context.platform, loginAccount.get.userName)'); + $('#repository-url').val('@context.urls(repository).sshUrl(loginAccount.get.userName)'); + $('#repository-clone-url').attr('href', '@context.urls(repository).sshOpenRepoUrl(context.platform, loginAccount.get.userName)'); $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); }); } diff --git a/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html b/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html index 9e0b876..c788a7f 100644 --- a/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html +++ b/src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html @@ -100,21 +100,21 @@ you can perform a manual merge on the command line.

} - @helper.html.copy("repository-url-copy", forkedRepository.urls(repoBase).httpUrl, true){ + @helper.html.copy("repository-url-copy", context.urls(forkedRepository).httpUrl, true){
@if(settings.ssh && loginAccount.isDefined){ }
- + }

Step 1: From your project repository, check out a new branch and test the changes.

@defining(s"git checkout -b ${pullreq.requestUserName}-${pullreq.requestBranch} ${pullreq.branch}\n" + - s"git pull ${forkedRepository.urls(repoBase).httpUrl} ${pullreq.requestBranch}"){ command => + s"git pull ${context.urls(forkedRepository).httpUrl} ${pullreq.requestBranch}"){ command => @helper.html.copy("merge-command-copy-1", command){
@Html(command)
} @@ -174,24 +174,24 @@ @if(settings.ssh && loginAccount.isDefined){ $('#repository-url-http').click(function(){ // Update URL box - $('#repository-url').val('@forkedRepository.urls(repoBase).httpUrl'); + $('#repository-url').val('@context.urls(forkedRepository).httpUrl'); $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); // Update command guidance $('#merge-command').text($('#merge-command').text().replace( - '@forkedRepository.urls(repoBase).sshUrl(loginAccount.get.userName)', - '@forkedRepository.urls(repoBase).httpUrl' + '@context.urls(forkedRepository).sshUrl(loginAccount.get.userName)', + '@context.urls(forkedRepository).httpUrl' )); $('#merge-command-copy-1').attr('data-clipboard-text', $('#merge-command').text()); }); $('#repository-url-ssh').click(function(){ // Update URL box - $('#repository-url').val('@forkedRepository.urls(repoBase).sshUrl(loginAccount.get.userName)'); + $('#repository-url').val('@context.urls(forkedRepository).sshUrl(loginAccount.get.userName)'); $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); // Update command guidance $('#merge-command').text($('#merge-command').text().replace( - '@forkedRepository.urls(repoBase).httpUrl', - '@forkedRepository.urls(repoBase).sshUrl(loginAccount.get.userName)' + '@context.urls(forkedRepository).httpUrl', + '@context.urls(forkedRepository).sshUrl(loginAccount.get.userName)' )); $('#merge-command-copy-1').attr('data-clipboard-text', $('#merge-command').text()); }); diff --git a/src/main/twirl/gitbucket/core/repo/guide.scala.html b/src/main/twirl/gitbucket/core/repo/guide.scala.html index e39d37b..5c064b4 100644 --- a/src/main/twirl/gitbucket/core/repo/guide.scala.html +++ b/src/main/twirl/gitbucket/core/repo/guide.scala.html @@ -10,10 +10,10 @@ } else {

Quick setup — if you've done this kind of thing before

- via HTTP + via HTTP @if(settings.ssh && loginAccount.isDefined){ or - SSH + SSH }

Create a new repository on the command line

@@ -22,12 +22,12 @@ git init git add README.md git commit -m "first commit" - git remote add origin @repository.urls(repoBase).httpUrl + git remote add origin @context.urls(repository).httpUrl git push -u origin master }

Push an existing repository from the command line

@pre { - git remote add origin @repository.urls(repoBase).httpUrl + git remote add origin @context.urls(repository).httpUrl git push -u origin master }