Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
48c906fe
Commit
48c906fe
authored
Nov 17, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix generated clone URLs for wikis on Geo secondaries
parent
7f9dac98
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
45 deletions
+72
-45
changelogs/unreleased-ee/4054-fix-geo-wiki-clone-instructions.yml
...gs/unreleased-ee/4054-fix-geo-wiki-clone-instructions.yml
+5
-0
ee/app/helpers/ee/gitlab_routing_helper.rb
ee/app/helpers/ee/gitlab_routing_helper.rb
+9
-9
spec/ee/spec/helpers/ee/gitlab_routing_helper_spec.rb
spec/ee/spec/helpers/ee/gitlab_routing_helper_spec.rb
+58
-36
No files found.
changelogs/unreleased-ee/4054-fix-geo-wiki-clone-instructions.yml
0 → 100644
View file @
48c906fe
---
title
:
Fix generated clone URLs for wikis on Geo secondaries
merge_request
:
3448
author
:
type
:
fixed
ee/app/helpers/ee/gitlab_routing_helper.rb
View file @
48c906fe
...
...
@@ -3,24 +3,24 @@ module EE
include
::
ProjectsHelper
include
::
ApplicationSettingsHelper
def
geo_primary_web_url
(
project
)
File
.
join
(
::
Gitlab
::
Geo
.
primary_node
.
url
,
::
Gitlab
::
Routing
.
url_helpers
.
project_path
(
project
)
)
def
geo_primary_web_url
(
project
_or_wiki
)
File
.
join
(
::
Gitlab
::
Geo
.
primary_node
.
url
,
project_or_wiki
.
full_path
)
end
def
geo_primary_ssh_url_to_repo
(
project
)
"
#{
::
Gitlab
::
Geo
.
primary_node
.
clone_url_prefix
}#{
project
.
full_path
}
.git"
def
geo_primary_ssh_url_to_repo
(
project
_or_wiki
)
"
#{
::
Gitlab
::
Geo
.
primary_node
.
clone_url_prefix
}#{
project
_or_wiki
.
full_path
}
.git"
end
def
geo_primary_http_url_to_repo
(
project
)
"
#{
geo_primary_web_url
(
project
)
}
.git"
def
geo_primary_http_url_to_repo
(
project
_or_wiki
)
geo_primary_web_url
(
project_or_wiki
)
+
'.git'
end
def
geo_primary_default_url_to_repo
(
project
)
def
geo_primary_default_url_to_repo
(
project
_or_wiki
)
case
default_clone_protocol
when
'ssh'
geo_primary_ssh_url_to_repo
(
project
)
geo_primary_ssh_url_to_repo
(
project
_or_wiki
)
else
geo_primary_http_url_to_repo
(
project
)
geo_primary_http_url_to_repo
(
project
_or_wiki
)
end
end
...
...
spec/ee/spec/helpers/ee/gitlab_routing_helper_spec.rb
View file @
48c906fe
...
...
@@ -4,63 +4,85 @@ describe EE::GitlabRoutingHelper do
include
ProjectsHelper
include
ApplicationSettingsHelper
let!
(
:primary_node
)
{
create
(
:geo_node
,
:primary
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
set
(
:primary
)
{
create
(
:geo_node
,
:primary
,
url:
'http://localhost:123/relative'
,
clone_url_prefix:
'git@localhost:'
)
}
set
(
:group
)
{
create
(
:group
,
path:
'foo'
)
}
set
(
:project
)
{
create
(
:project
,
namespace:
group
,
path:
'bar'
)
}
describe
'#geo_primary_
default_url_to_repo
'
do
it
'returns an HTTP URL'
do
describe
'#geo_primary_
web_url
'
do
before
do
allow
(
helper
).
to
receive
(
:default_clone_protocol
).
and_return
(
'http'
)
end
result
=
helper
.
geo_primary_default_url_to_repo
(
project
)
it
'generates a path to the project'
do
result
=
helper
.
geo_primary_web_url
(
project
)
expect
(
result
).
to
start_with
(
'http://'
)
expect
(
result
).
to
eq
(
helper
.
geo_primary_http_url_to_repo
(
project
))
expect
(
result
).
to
eq
(
'http://localhost:123/relative/foo/bar'
)
end
it
'returns an HTTPS URL'
do
primary_node
.
update_attribute
(
:schema
,
'https'
)
allow
(
helper
).
to
receive
(
:default_clone_protocol
).
and_return
(
'https'
)
result
=
helper
.
geo_primary_default_url_to_repo
(
project
)
it
'generates a path to the wiki'
do
result
=
helper
.
geo_primary_web_url
(
project
.
wiki
)
expect
(
result
).
to
start_with
(
'https://'
)
expect
(
result
).
to
eq
(
helper
.
geo_primary_http_url_to_repo
(
project
))
expect
(
result
).
to
eq
(
'http://localhost:123/relative/foo/bar.wiki'
)
end
end
it
'returns an SSH URL
'
do
allow
(
helper
).
to
receive
(
:default_clone_protocol
).
and_return
(
'ssh'
)
describe
'#geo_primary_default_url_to_repo
'
do
subject
{
helper
.
geo_primary_default_url_to_repo
(
repo
)
}
result
=
helper
.
geo_primary_default_url_to_repo
(
project
)
context
'HTTP'
do
before
do
allow
(
helper
).
to
receive
(
:default_clone_protocol
).
and_return
(
'http'
)
primary
.
update!
(
schema:
'http'
)
end
expect
(
result
).
to
start_with
(
'git@'
)
expect
(
result
).
to
eq
(
helper
.
geo_primary_ssh_url_to_repo
(
project
))
end
end
context
'project'
do
let
(
:repo
)
{
project
}
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
)
it
{
is_expected
.
to
eq
(
'http://localhost:123/relative/foo/bar.git'
)
}
end
expect
(
result
).
to
eq
(
"http://localhost/
#{
project
.
full_path
}
.git"
)
context
'wiki'
do
let
(
:repo
)
{
project
.
wiki
}
it
{
is_expected
.
to
eq
(
'http://localhost:123/relative/foo/bar.wiki.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
)
context
'HTTPS'
do
before
do
allow
(
helper
).
to
receive
(
:default_clone_protocol
).
and_return
(
'https'
)
primary
.
update!
(
schema:
'https'
)
end
context
'project'
do
let
(
:repo
)
{
project
}
it
{
is_expected
.
to
eq
(
'https://localhost:123/relative/foo/bar.git'
)
}
end
context
'wiki'
do
let
(
:repo
)
{
project
.
wiki
}
expect
(
result
).
to
eq
(
"https://localhost/
#{
project
.
full_path
}
.git"
)
it
{
is_expected
.
to
eq
(
'https://localhost:123/relative/foo/bar.wiki.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
)
context
'SSH'
do
before
do
allow
(
helper
).
to
receive
(
:default_clone_protocol
).
and_return
(
'ssh'
)
end
expect
(
result
).
to
eq
(
"git@localhost:
#{
project
.
full_path
}
.git"
)
context
'project'
do
let
(
:repo
)
{
project
}
it
{
is_expected
.
to
eq
(
'git@localhost:foo/bar.git'
)
}
end
context
'wiki'
do
let
(
:repo
)
{
project
.
wiki
}
it
{
is_expected
.
to
eq
(
'git@localhost:foo/bar.wiki.git'
)
}
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment