lib/abak-flow/request.rb in abak-flow-0.2.1 vs lib/abak-flow/request.rb in abak-flow-0.2.2

- old
+ new

@@ -26,14 +26,20 @@ remote_branch, task = current_branch.split('/').push(nil).map(&:to_s) title = args.first.to_s.strip title = task if task =~ /^\w+\-\d{1,}$/ && title.empty? - api_user = Hub::Commands.send(:git_reader).read_config('abak.apiuser') - api_token = Hub::Commands.send(:git_reader).read_config('abak.apitoken') - api_client = Octokit::Client.new(:login => api_user, :oauth_token => api_token) + api_user = Hub::Commands.send(:git_reader).read_config('abak.apiuser') + api_token = Hub::Commands.send(:git_reader).read_config('abak.apitoken') + config_proxy = Hub::Commands.send(:git_reader).read_config('abak.proxy') + env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] + client_opts = {:proxy => config_proxy || env_proxy} if config_proxy || env_proxy + client_opts ||= {} + + api_client = Octokit::Client.new({:login => api_user, :oauth_token => api_token}.merge(client_opts)) + # Проверим, что мы не в мастере или девелопе if [:master, :develop].include? current_branch.to_sym say color('Нельзя делать pull request из меток master или develop', :error).to_s exit end @@ -221,12 +227,14 @@ c.action do |args, options| HighLine.color_scheme = HighLine::SampleColorScheme.new repository = Hub::Commands.send :local_repo current_branch = repository.current_branch.short_name - api_user = Hub::Commands.send(:git_reader).read_config('abak.apiuser').to_s - api_token = Hub::Commands.send(:git_reader).read_config('abak.apitoken').to_s + api_user = Hub::Commands.send(:git_reader).read_config('abak.apiuser').to_s + api_token = Hub::Commands.send(:git_reader).read_config('abak.apitoken').to_s + config_proxy = Hub::Commands.send(:git_reader).read_config('abak.proxy') + env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] errors = [] # Проверим, что у нас настроен origin if repository.remote_by_name('origin').nil? @@ -256,9 +264,16 @@ if api_token.empty? errors << [ 'Необходимо указать токен своего пользователя API github', '=> https://github.com/Strech/abak-flow/blob/master/README.md' ] + end + + if config_proxy || env_proxy + message = "== В качестве прокси будет установлено значение #{config_proxy || env_proxy} ==" + say color('=' * message.length, :info).to_s + say color(message, :info).to_s + say color('=' * message.length + "\n", :info).to_s end errors.each do |error| say "#{color(error.first, :error)}\n#{color(error.last, :info)}" end \ No newline at end of file