lib/travis/cli/api_command.rb in travis-1.5.3 vs lib/travis/cli/api_command.rb in travis-1.5.4
- old
+ new
@@ -29,11 +29,11 @@
require 'typhoeus/adapters/faraday' if adapter == 'typhoeus'
c.session.faraday_adapter = adapter.to_sym
end
def initialize(*)
- @session = Travis::Client.new
+ @session = Travis::Client.new(:agent_info => "command #{command_name}")
super
end
def endpoint_config
config['endpoints'] ||= {}
@@ -77,9 +77,27 @@
end
end
end
private
+
+ def load_gh
+ return if defined? GH
+ require 'gh'
+
+ gh_config = session.config['github']
+ gh_config &&= gh_config.inject({}) { |h,(k,v)| h.update(k.to_sym => v) }
+ gh_config ||= {}
+ gh_config[:ssl] = Travis::Client::Session::SSL_OPTIONS
+ gh_config[:ssl] = { :verify => false } if gh_config[:api_url] and gh_config[:api_url] != "https://api.github.com"
+
+ GH.set(gh_config)
+ end
+
+ def github_endpoint
+ load_gh
+ GH.with({}).api_host
+ end
def listen(*args)
super(*args) do |listener|
on_signal { listener.disconnect }
yield listener