diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-07-14 13:43:25 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-08-07 13:06:12 -0300 |
commit | 51186e72c5b06e144960bd0caf9684dbc387920c (patch) | |
tree | 67c7cbba93f5b3a9c8c763ff530ec91402134d12 /lib/github | |
parent | 81995317f99550a0cd5c76e9b15fd91364665d1f (diff) | |
download | gitlab-ce-51186e72c5b06e144960bd0caf9684dbc387920c.tar.gz |
Use a custom root endpoint if defined on GH ominiauth provider settings
Diffstat (limited to 'lib/github')
-rw-r--r-- | lib/github/import.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/github/import.rb b/lib/github/import.rb index fd4059c612e..69bc5f08d9a 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -48,9 +48,9 @@ module Github @project = project @repository = project.repository @repo = project.import_source - @options = options @repo_url = project.import_url @wiki_url = project.import_url.sub(/\.git\z/, '.wiki.git') + @options = options.reverse_merge(url: root_endpoint) @verbose = options.fetch(:verbose, false) @cached = Hash.new { |hash, key| hash[key] = Hash.new } @errors = [] @@ -383,5 +383,20 @@ 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 |