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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a7363d4a
Commit
a7363d4a
authored
Jul 17, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move GitHub root endpoint methods to Github::Client
parent
51186e72
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
+19
-17
lib/github/client.rb
lib/github/client.rb
+18
-1
lib/github/import.rb
lib/github/import.rb
+1
-16
No files found.
lib/github/client.rb
View file @
a7363d4a
...
...
@@ -3,7 +3,7 @@ module Github
attr_reader
:connection
,
:rate_limit
def
initialize
(
options
)
@connection
=
Faraday
.
new
(
url:
options
.
fetch
(
:url
))
do
|
faraday
|
@connection
=
Faraday
.
new
(
url:
options
.
fetch
(
:url
,
root_endpoint
))
do
|
faraday
|
faraday
.
options
.
open_timeout
=
options
.
fetch
(
:timeout
,
60
)
faraday
.
options
.
timeout
=
options
.
fetch
(
:timeout
,
60
)
faraday
.
authorization
'token'
,
options
.
fetch
(
:token
)
...
...
@@ -19,5 +19,22 @@ module Github
Github
::
Response
.
new
(
connection
.
get
(
url
,
query
))
end
private
def
root_endpoint
custom_endpoint
||
githup_endpoint
end
def
custom_endpoint
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'github'
}
.
to_h
.
dig
(
'args'
,
'client_options'
,
'site'
)
end
def
github_endpoint
OmniAuth
::
Strategies
::
GitHub
.
default_options
[
:client_options
][
:site
]
end
end
end
lib/github/import.rb
View file @
a7363d4a
...
...
@@ -50,7 +50,7 @@ module Github
@repo
=
project
.
import_source
@repo_url
=
project
.
import_url
@wiki_url
=
project
.
import_url
.
sub
(
/\.git\z/
,
'.wiki.git'
)
@options
=
options
.
reverse_merge
(
url:
root_endpoint
)
@options
=
options
@verbose
=
options
.
fetch
(
:verbose
,
false
)
@cached
=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
Hash
.
new
}
@errors
=
[]
...
...
@@ -383,20 +383,5 @@ module Github
def
error
(
type
,
url
,
message
)
errors
<<
{
type:
type
,
url:
Gitlab
::
UrlSanitizer
.
sanitize
(
url
),
error:
message
}
end
def
root_endpoint
@root_endpoint
||=
custom_endpoint
||
githup_endpoint
end
def
custom_endpoint
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
'github'
}
.
to_h
.
dig
(
'args'
,
'client_options'
,
'site'
)
end
def
github_endpoint
OmniAuth
::
Strategies
::
GitHub
.
default_options
[
:client_options
][
:site
]
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