diff --git a/lib/commands/helpers.rb b/lib/commands/helpers.rb index 4439ccb9..e4c83d6e 100644 --- a/lib/commands/helpers.rb +++ b/lib/commands/helpers.rb @@ -334,8 +334,9 @@ if cache_network_data(options) begin return cache_data(user) - rescue SocketError + rescue Exception => e STDERR.puts "*** Warning: There was a problem accessing the network." + STDERR.puts e rv = get_cache STDERR.puts "Using cached data." rv @@ -373,12 +374,17 @@ File.join(dir, 'commits-cache') end +helper :github_user do + `git config --get github.user`.chomp +end + +helper :github_token do + `git config --get github.token`.chomp +end + helper :cache_data do |user| - raw_data = Kernel.open(network_meta_for(user)).read - File.open( network_cache_path, 'w' ) do |out| - out.write(raw_data) - end - data = JSON.parse(raw_data) + `curl -s -L -F 'login=#{github_user}' -F 'token=#{github_token}' #{network_meta_for(user)} -o #{network_cache_path}` + get_cache end helper :cache_expired? do diff --git a/lib/github/ui.rb b/lib/github/ui.rb index a19c1922..1035e4f4 100644 --- a/lib/github/ui.rb +++ b/lib/github/ui.rb @@ -1,3 +1,4 @@ +require 'rubygems' require "readline" require "highline" module GitHub