Commit 8b8e169d authored by Robert Speicher's avatar Robert Speicher

Merge branch '2813-fix-clone_url-for-geo' into 'master'

Geo: Fix clone instructions in a secondary node for SSH protocol

Closes #2813

See merge request !2319
parents 37c3bf89 2abafbc4
......@@ -84,7 +84,8 @@ module ButtonHelper
html: true,
placement: placement,
container: 'body',
title: _('Add an SSH key to your profile to pull or push via SSH.')
title: _('Add an SSH key to your profile to pull or push via SSH.'),
primary_url: (geo_primary_ssh_url_to_repo(project) if Gitlab::Geo.secondary?)
}
end
......
......@@ -8,7 +8,7 @@ module EE
end
def geo_primary_ssh_url_to_repo(project)
"#{::Gitlab::Geo.primary_node.clone_url_prefix}#{project.path_with_namespace}"
"#{::Gitlab::Geo.primary_node.clone_url_prefix}#{project.path_with_namespace}.git"
end
def geo_primary_http_url_to_repo(project)
......
......@@ -21,7 +21,8 @@
remote:
= clipboard_button(target: 'pre#geo-info-2')
%pre#geo-info-2.dark
git remote set-url --push origin #{geo_primary_default_url_to_repo(project)}
git remote set-url --push origin <clone url for primary repository>
%p
%strong= 'Done.'
......
---
title: 'Geo: Fix clone instructions in a secondary node for SSH protocol'
merge_request: 2319
author:
......@@ -36,4 +36,31 @@ describe EE::GitlabRoutingHelper do
expect(result).to eq(helper.geo_primary_ssh_url_to_repo(project))
end
end
describe '#geo_primary_http_url_to_repo' do
context 'when using http protocol' do
it 'returns a url in format http://hostname/namespace/repo.git' do
result = helper.geo_primary_http_url_to_repo(project)
expect(result).to eq("http://localhost/#{project.full_path}.git")
end
end
context 'when using https protocol' do
it 'returns a url in format https://hostname/namespace/repo.git' do
primary_node.update_attributes(schema: 'https', port: 443)
result = helper.geo_primary_http_url_to_repo(project)
expect(result).to eq("https://localhost/#{project.full_path}.git")
end
end
end
describe '#geo_primary_ssh_url_to_repo' do
it 'returns a url in format user@host:namespace/repo.git' do
result = helper.geo_primary_ssh_url_to_repo(project)
expect(result).to eq("git@localhost:#{project.full_path}.git")
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment