From 3726b5e0f1f1129e41550f753e1d2207a3f5063c Mon Sep 17 00:00:00 2001 From: Jonathan Lim Date: Sat, 28 Nov 2009 13:55:38 +0000 Subject: [PATCH 1/2] Fix for accessing private repository network meta --- lib/commands/helpers.rb | 20 +++++++++++++------- lib/github/ui.rb | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/commands/helpers.rb b/lib/commands/helpers.rb index d742fb3c..f77146d1 100644 --- a/lib/commands/helpers.rb +++ b/lib/commands/helpers.rb @@ -247,7 +247,7 @@ end helper :network_meta_for do |user| - "http://github.com/#{user}/#{project}/network_meta" + "https://github.com/#{user}/#{project}/network_meta" end helper :issues_page_for do |user| @@ -332,8 +332,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 @@ -371,12 +372,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 -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 From df4893a6c14e4b74c6efbb7c3b09638914549ea1 Mon Sep 17 00:00:00 2001 From: Jonathan Lim Date: Mon, 30 Nov 2009 12:09:51 +0000 Subject: [PATCH 2/2] Making curl silent, as suggested by chuckd in http://github.com/defunkt/github-gem/issues#issue/4/comment/82295 --- lib/commands/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/helpers.rb b/lib/commands/helpers.rb index f77146d1..e953faa3 100644 --- a/lib/commands/helpers.rb +++ b/lib/commands/helpers.rb @@ -381,7 +381,7 @@ end helper :cache_data do |user| - `curl -L -F 'login=#{github_user}' -F 'token=#{github_token}' #{network_meta_for(user)} -o #{network_cache_path}` + `curl -s -L -F 'login=#{github_user}' -F 'token=#{github_token}' #{network_meta_for(user)} -o #{network_cache_path}` get_cache end