mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
(refs #326)SSH clone URL includes username for logged-in users and it's hidden for non logged-in users.
This commit is contained in:
@@ -294,7 +294,7 @@ object RepositoryService {
|
||||
|
||||
lazy val host = """^https?://(.+?)(:\d+)?/""".r.findFirstMatchIn(httpUrl).get.group(1)
|
||||
|
||||
def sshUrl(port: Int) = s"ssh://${host}:${port}/${owner}/${name}.git"
|
||||
def sshUrl(port: Int, userName: String) = s"ssh://${userName}@${host}:${port}/${owner}/${name}.git"
|
||||
|
||||
/**
|
||||
* Creates instance with issue count and pull request count.
|
||||
|
||||
@@ -43,8 +43,8 @@ object WikiService {
|
||||
|
||||
def httpUrl(repository: RepositoryInfo) = repository.httpUrl.replaceFirst("\\.git\\Z", ".wiki.git")
|
||||
|
||||
def sshUrl(repository: RepositoryInfo, settings: SystemSettingsService.SystemSettings) =
|
||||
repository.sshUrl(settings.sshPort.getOrElse(SystemSettingsService.DefaultSshPort)).replaceFirst("\\.git\\Z", ".wiki.git")
|
||||
def sshUrl(repository: RepositoryInfo, settings: SystemSettingsService.SystemSettings, userName: String) =
|
||||
repository.sshUrl(settings.sshPort.getOrElse(SystemSettingsService.DefaultSshPort), userName).replaceFirst("\\.git\\Z", ".wiki.git")
|
||||
}
|
||||
|
||||
trait WikiService {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<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">
|
||||
@helper.html.copy("repository-url-copy", repository.httpUrl, true){
|
||||
@if(settings.ssh){
|
||||
@if(settings.ssh && loginAccount.isDefined){
|
||||
<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>
|
||||
</div>
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@if(settings.ssh){
|
||||
@if(settings.ssh && loginAccount.isDefined){
|
||||
<script>
|
||||
$(function(){
|
||||
$('#repository-url-http').click(function(){
|
||||
@@ -47,7 +47,7 @@ $(function(){
|
||||
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
||||
});
|
||||
$('#repository-url-ssh').click(function(){
|
||||
$('#repository-url').val('@repository.sshUrl(settings.sshPort.getOrElse(service.SystemSettingsService.DefaultSshPort))');
|
||||
$('#repository-url').val('@repository.sshUrl(settings.sshPort.getOrElse(service.SystemSettingsService.DefaultSshPort), loginAccount.get.userName)');
|
||||
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<li@if(active == "history"){ class="active"}><a href="@url(repository)/wiki/_history">Wiki History</a></li>
|
||||
<li class="pull-right">
|
||||
@helper.html.copy("repository-url-copy", httpUrl(repository), true){
|
||||
@if(settings.ssh){
|
||||
@if(settings.ssh && loginAccount.isDefined){
|
||||
<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>
|
||||
</div>
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
</li>
|
||||
</ul>
|
||||
@if(settings.ssh){
|
||||
@if(settings.ssh && loginAccount.isDefined){
|
||||
<script>
|
||||
$(function(){
|
||||
$('#repository-url-http').click(function(){
|
||||
@@ -28,7 +28,7 @@ $(function(){
|
||||
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
||||
});
|
||||
$('#repository-url-ssh').click(function(){
|
||||
$('#repository-url').val('@sshUrl(repository, settings)');
|
||||
$('#repository-url').val('@sshUrl(repository, settings, loginAccount.get.userName)');
|
||||
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user