mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
(refs #115)Add new method to get sshUrl to RepositoryInfo
This commit is contained in:
@@ -288,10 +288,14 @@ trait RepositoryService { self: AccountService =>
|
|||||||
|
|
||||||
object RepositoryService {
|
object RepositoryService {
|
||||||
|
|
||||||
case class RepositoryInfo(owner: String, name: String, url: String, repository: Repository,
|
case class RepositoryInfo(owner: String, name: String, httpUrl: String, repository: Repository,
|
||||||
issueCount: Int, pullCount: Int, commitCount: Int, forkedCount: Int,
|
issueCount: Int, pullCount: Int, commitCount: Int, forkedCount: Int,
|
||||||
branchList: Seq[String], tags: Seq[util.JGitUtil.TagInfo], managers: Seq[String]){
|
branchList: Seq[String], tags: Seq[util.JGitUtil.TagInfo], managers: Seq[String]){
|
||||||
|
|
||||||
|
lazy val host = """^https?://(.+?)(:\d+)?/""".r.findFirstMatchIn(httpUrl).get.group(1)
|
||||||
|
|
||||||
|
def sshUrl(port: Int) = s"ssh://${host}:${port}/${owner}/${name}.git"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates instance with issue count and pull request count.
|
* Creates instance with issue count and pull request count.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ object WebHookService {
|
|||||||
refName,
|
refName,
|
||||||
commits.map { commit =>
|
commits.map { commit =>
|
||||||
val diffs = JGitUtil.getDiffs(git, commit.id, false)
|
val diffs = JGitUtil.getDiffs(git, commit.id, false)
|
||||||
val commitUrl = repositoryInfo.url.replaceFirst("/git/", "/").replaceFirst("\\.git$", "") + "/commit/" + commit.id
|
val commitUrl = repositoryInfo.httpUrl.replaceFirst("/git/", "/").replaceFirst("\\.git$", "") + "/commit/" + commit.id
|
||||||
|
|
||||||
WebHookCommit(
|
WebHookCommit(
|
||||||
id = commit.id,
|
id = commit.id,
|
||||||
@@ -106,7 +106,7 @@ object WebHookService {
|
|||||||
}.toList,
|
}.toList,
|
||||||
WebHookRepository(
|
WebHookRepository(
|
||||||
name = repositoryInfo.name,
|
name = repositoryInfo.name,
|
||||||
url = repositoryInfo.url,
|
url = repositoryInfo.httpUrl,
|
||||||
description = repositoryInfo.repository.description.getOrElse(""),
|
description = repositoryInfo.repository.description.getOrElse(""),
|
||||||
watchers = 0,
|
watchers = 0,
|
||||||
forks = repositoryInfo.forkedCount,
|
forks = repositoryInfo.forkedCount,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class GitBucketLinkRender(context: app.Context, repository: service.RepositorySe
|
|||||||
(text, text)
|
(text, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
val url = repository.url.replaceFirst("/git/", "/").replaceFirst("\\.git$", "") + "/wiki/" + StringUtil.urlEncode(page)
|
val url = repository.httpUrl.replaceFirst("/git/", "/").replaceFirst("\\.git$", "") + "/wiki/" + StringUtil.urlEncode(page)
|
||||||
|
|
||||||
if(getWikiPage(repository.owner, repository.name, page).isDefined){
|
if(getWikiPage(repository.owner, repository.name, page).isDefined){
|
||||||
new Rendering(url, label)
|
new Rendering(url, label)
|
||||||
@@ -104,7 +104,7 @@ class GitBucketHtmlSerializer(
|
|||||||
if(!enableWikiLink || url.startsWith("http://") || url.startsWith("https://")){
|
if(!enableWikiLink || url.startsWith("http://") || url.startsWith("https://")){
|
||||||
url
|
url
|
||||||
} else {
|
} else {
|
||||||
repository.url.replaceFirst("/git/", "/").replaceFirst("\\.git$", "") + "/wiki/_blob/" + url
|
repository.httpUrl.replaceFirst("/git/", "/").replaceFirst("\\.git$", "") + "/wiki/_blob/" + url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ touch README.md
|
|||||||
git init
|
git init
|
||||||
git add README.md
|
git add README.md
|
||||||
git commit -m "first commit"
|
git commit -m "first commit"
|
||||||
git remote add origin @repository.url
|
git remote add origin @repository.httpUrl
|
||||||
git push -u origin master
|
git push -u origin master
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3 style="margin-top: 30px;">Push an existing repository from the command line</h3>
|
<h3 style="margin-top: 30px;">Push an existing repository from the command line</h3>
|
||||||
<pre>
|
<pre>
|
||||||
git remote add origin @repository.url
|
git remote add origin @repository.httpUrl
|
||||||
git push -u origin master
|
git push -u origin master
|
||||||
</pre>
|
</pre>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<li@if(active=="branches"){ class="active"}><a href="@url(repository)/branches">Branches@if(repository.branchList.length > 0){ <span class="badge">@repository.branchList.length</span>}</a></li>
|
<li@if(active=="branches"){ class="active"}><a href="@url(repository)/branches">Branches@if(repository.branchList.length > 0){ <span class="badge">@repository.branchList.length</span>}</a></li>
|
||||||
<li@if(active=="tags" ){ class="active"}><a href="@url(repository)/tags">Tags@if(repository.tags.length > 0){ <span class="badge">@repository.tags.length</span>}</a></li>
|
<li@if(active=="tags" ){ class="active"}><a href="@url(repository)/tags">Tags@if(repository.tags.length > 0){ <span class="badge">@repository.tags.length</span>}</a></li>
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
@helper.html.copy("repository-url-copy", repository.url, true){
|
@helper.html.copy("repository-url-copy", repository.httpUrl, true){
|
||||||
@if(settings.ssh){
|
@if(settings.ssh){
|
||||||
<div class="btn-group add-on" data-toggle="buttons-radio" style="padding: 0px; border-width: 0px;">
|
<div class="btn-group add-on" data-toggle="buttons-radio" style="padding: 0px; border-width: 0px;">
|
||||||
<button type="button" class="btn active" id="repository-url-http">HTTP</button><button type="button" class="btn" id="repository-url-ssh">SSH</button>
|
<button type="button" class="btn active" id="repository-url-http">HTTP</button><button type="button" class="btn" id="repository-url-ssh">SSH</button>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
} else {
|
} else {
|
||||||
<span class="add-on">HTTP</span>
|
<span class="add-on">HTTP</span>
|
||||||
}
|
}
|
||||||
<input type="text" value="@repository.url" id="repository-url" style="width: 150px;" readonly>
|
<input type="text" value="@repository.httpUrl" id="repository-url" style="width: 150px;" readonly>
|
||||||
}
|
}
|
||||||
</li>
|
</li>
|
||||||
<li class="pull-right" style="margin-right: 8px;">
|
<li class="pull-right" style="margin-right: 8px;">
|
||||||
@@ -44,12 +44,11 @@
|
|||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$('#repository-url-http').click(function(){
|
$('#repository-url-http').click(function(){
|
||||||
$('#repository-url').val('@repository.url');
|
$('#repository-url').val('@repository.httpUrl');
|
||||||
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
||||||
});
|
});
|
||||||
$('#repository-url-ssh').click(function(){
|
$('#repository-url-ssh').click(function(){
|
||||||
// TODO How should I make a url for ssh access?
|
$('#repository-url').val('@repository.sshUrl(settings.sshPort.get)'); // TODO apply default value for None?
|
||||||
$('#repository-url').val('ssh://localhost:29418/@repository.owner/@repository.name');
|
|
||||||
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<li@if(active == "pages" ){ class="active"}><a href="@url(repository)/wiki/_pages">Pages</a></li>
|
<li@if(active == "pages" ){ class="active"}><a href="@url(repository)/wiki/_pages">Pages</a></li>
|
||||||
<li@if(active == "history"){ class="active"}><a href="@url(repository)/wiki/_history">Wiki History</a></li>
|
<li@if(active == "history"){ class="active"}><a href="@url(repository)/wiki/_history">Wiki History</a></li>
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
@defining(repository.url.replaceFirst("\\.git$", ".wiki.git")){ repositoryUrl =>
|
@defining(repository.httpUrl.replaceFirst("\\.git$", ".wiki.git")){ repositoryUrl =>
|
||||||
@helper.html.copy("repository-url-copy", repositoryUrl){
|
@helper.html.copy("repository-url-copy", repositoryUrl){
|
||||||
<input type="text" value="@repositoryUrl" readonly id="repository-url">
|
<input type="text" value="@repositoryUrl" readonly id="repository-url">
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user