From 88217029fc37e972fd84aec7eb9a77247a9532bf Mon Sep 17 00:00:00 2001 From: Eirik Lygre <eirik.lygre@gmail.com> Date: Sun, 6 Dec 2015 20:48:04 +0100 Subject: [PATCH] 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. --- app/helpers/projects_helper.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 48729e5260..22db8d860e 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -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) -- 2.30.9