When rendering the clone page, check user profile to decide default clone protocol. If the user has uploaded SSH-keys, use SSH; otherwise, use http(s). Close #3504.

This commit is contained in:
Eirik Lygre 2015-12-06 20:48:04 +01:00
parent 234f4bf20f
commit 88217029fc

View file

@ -175,11 +175,21 @@ module ProjectsHelper
end
def default_url_to_repo(project = @project)
current_user ? project.url_to_repo : project.http_url_to_repo
if default_clone_protocol == "ssh"
project.ssh_url_to_repo
else
project.http_url_to_repo
end
end
def default_clone_protocol
current_user ? "ssh" : "http"
if !current_user
"http"
elsif current_user.require_ssh_key?
"http"
else
"ssh"
end
end
def project_last_activity(project)