Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Commit f32c916

Browse files
committed
fix user_sync/repositories to not explode on GH errors
1 parent b4c4ae9 commit f32c916

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/travis/github/services/sync_user/repositories.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ def slugs
9090
end
9191

9292
def fetch
93-
resources.map { |resource| fetch_resource(resource) }.map(&:to_a).flatten.compact
93+
resources.map { |resource| fetch_resource(resource) }.compact.map(&:to_a).flatten
9494
end
9595
instrument :fetch, :level => :debug
9696

9797
def fetch_resource(resource)
9898
GH[resource] # TODO should be: ?type=#{self.class.type} but GitHub doesn't work as documented
9999
rescue GH::Error => e
100100
log_exception(e)
101+
nil
101102
end
102103

103104
def with_github(&block)

spec/travis/github/services/sync_user/repositories_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@
127127
sync.run
128128
end
129129
end
130+
131+
it 'does not explode on GH errors' do
132+
GH.expects(:[]).with('user/repos').raises(GH::Error.new)
133+
expect { sync.run }.to_not raise_error
134+
end
130135
end
131136

132137
describe Travis::Github::Services::SyncUser::Repositories::Instrument do

0 commit comments

Comments
 (0)