BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
afe2c15e
Commit
afe2c15e
authored
Mar 12, 2018
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix provider server URL used when listing repos to import
Also use Gitlab::Auth::OAuth::Provider.config_for to access OmniAuth config
parent
afd2d381
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
18 deletions
+46
-18
import_helper.rb
app/helpers/import_helper.rb
+8
-5
34604-fix-generated-url-for-external-repository.yml
...eased/34604-fix-generated-url-for-external-repository.yml
+5
-0
config.rb
lib/gitlab/auth/saml/config.rb
+1
-1
client.rb
lib/gitlab/github_import/client.rb
+1
-4
client.rb
lib/gitlab/gitlab_import/client.rb
+1
-1
client.rb
lib/gitlab/legacy_github_import/client.rb
+1
-1
auth.rb
lib/google_api/auth.rb
+1
-1
import_helper_spec.rb
spec/helpers/import_helper_spec.rb
+28
-5
No files found.
app/helpers/import_helper.rb
View file @
afe2c15e
module
ImportHelper
include
::
Gitlab
::
Utils
::
StrongMemoize
def
has_ci_cd_only_params?
false
end
...
...
@@ -75,17 +77,18 @@ module ImportHelper
private
def
github_project_url
(
full_path
)
"
#{
github_root_url
}
/
#{
full_path
}
"
URI
.
join
(
github_root_url
,
full_path
).
to_s
end
def
github_root_url
return
@github_url
if
defined?
(
@github_url
)
strong_memoize
(
:github_url
)
do
provider
=
Gitlab
::
Auth
::
OAuth
::
Provider
.
config_for
(
'github'
)
provider
=
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
p
|
p
.
name
==
'github'
}
@github_url
=
provider
.
fetch
(
'url'
,
'https://github.com'
)
if
provider
provider
&
.
dig
(
'url'
).
presence
||
'https://github.com'
end
end
def
gitea_project_url
(
full_path
)
"
#{
@gitea_host_url
.
sub
(
%r{/+
\z
}
,
''
)
}
/
#{
full_path
}
"
URI
.
join
(
@gitea_host_url
,
full_path
).
to_s
end
end
changelogs/unreleased/34604-fix-generated-url-for-external-repository.yml
0 → 100644
View file @
afe2c15e
---
title
:
Fix generated URL when listing repoitories for import
merge_request
:
17692
author
:
type
:
fixed
lib/gitlab/auth/saml/config.rb
View file @
afe2c15e
...
...
@@ -4,7 +4,7 @@ module Gitlab
class
Config
class
<<
self
def
options
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'saml'
}
Gitlab
::
Auth
::
OAuth
::
Provider
.
config_for
(
'saml'
)
end
def
groups
...
...
lib/gitlab/github_import/client.rb
View file @
afe2c15e
...
...
@@ -197,10 +197,7 @@ module Gitlab
end
def
github_omniauth_provider
@github_omniauth_provider
||=
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'github'
}
.
to_h
@github_omniauth_provider
||=
Gitlab
::
Auth
::
OAuth
::
Provider
.
config_for
(
'github'
).
to_h
end
def
rate_limit_counter
...
...
lib/gitlab/gitlab_import/client.rb
View file @
afe2c15e
...
...
@@ -72,7 +72,7 @@ module Gitlab
end
def
config
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
"gitlab"
}
Gitlab
::
Auth
::
OAuth
::
Provider
.
config_for
(
'gitlab'
)
end
def
gitlab_options
...
...
lib/gitlab/legacy_github_import/client.rb
View file @
afe2c15e
...
...
@@ -83,7 +83,7 @@ module Gitlab
end
def
config
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
"github"
}
Gitlab
::
Auth
::
OAuth
::
Provider
.
config_for
(
'github'
)
end
def
github_options
...
...
lib/google_api/auth.rb
View file @
afe2c15e
...
...
@@ -32,7 +32,7 @@ module GoogleApi
private
def
config
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
"google_oauth2"
}
Gitlab
::
Auth
::
OAuth
::
Provider
.
config_for
(
'google_oauth2'
)
end
def
client
...
...
spec/helpers/import_helper_spec.rb
View file @
afe2c15e
...
...
@@ -27,25 +27,48 @@ describe ImportHelper do
describe
'#provider_project_link'
do
context
'when provider is "github"'
do
let
(
:github_server_url
)
{
nil
}
before
do
setting
=
Settingslogic
.
new
(
'name'
=>
'github'
)
setting
[
'url'
]
=
github_server_url
if
github_server_url
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
and_return
([
setting
])
end
context
'when provider does not specify a custom URL'
do
it
'uses default GitHub URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
)
.
and_return
([
Settingslogic
.
new
(
'name'
=>
'github'
)])
expect
(
helper
.
provider_project_link
(
'github'
,
'octocat/Hello-World'
))
.
to
include
(
'href="https://github.com/octocat/Hello-World"'
)
end
end
context
'when provider specify a custom URL'
do
let
(
:github_server_url
)
{
'https://github.company.com'
}
it
'uses custom URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
)
.
and_return
([
Settingslogic
.
new
(
'name'
=>
'github'
,
'url'
=>
'https://github.company.com'
)])
expect
(
helper
.
provider_project_link
(
'github'
,
'octocat/Hello-World'
))
.
to
include
(
'href="https://github.company.com/octocat/Hello-World"'
)
end
end
context
"when custom URL contains a '/' char at the end"
do
let
(
:github_server_url
)
{
'https://github.company.com/'
}
it
"doesn't render double slash"
do
expect
(
helper
.
provider_project_link
(
'github'
,
'octocat/Hello-World'
))
.
to
include
(
'href="https://github.company.com/octocat/Hello-World"'
)
end
end
context
'when provider is missing'
do
it
'uses the default URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
and_return
([])
expect
(
helper
.
provider_project_link
(
'github'
,
'octocat/Hello-World'
))
.
to
include
(
'href="https://github.com/octocat/Hello-World"'
)
end
end
end
context
'when provider is "gitea"'
do
...
...
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