Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/jekyll-github-metadata/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def save_from_errors(default = false)
rescue Faraday::ConnectionFailed, Octokit::TooManyRequests => e
GitHubMetadata.log :warn, e.message
default
rescue Octokit::Forbidden => e
GitHubMetadata.log :warn, "#{e.message} This is a limitation of the GitHub API."
default
rescue Octokit::NotFound
default
end
Expand Down
17 changes: 17 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@
end.to raise_error(described_class::BadCredentialsError)
end

it "warns and returns false when contributors list is too large" do
stub_request(:get, url("/repos/jekyll/github-metadata/contributors?per_page=100"))
.with(:headers => request_headers.merge(
"Authorization" => "token #{token}"
))
.to_return(
:status => 403,
:headers => WebMockHelper::RESPONSE_HEADERS,
:body => webmock_data("contributors_forbidden")
)
logger_output = StringIO.new
Jekyll::GitHubMetadata.logger = Logger.new(logger_output)
result = subject.contributors("jekyll/github-metadata")
expect(result).to be(false)
expect(logger_output.string).to include("This is a limitation of the GitHub API")
end

it "supresses network accesses if requested" do
WebMock.disable_net_connect!

Expand Down
4 changes: 4 additions & 0 deletions spec/webmock/api_get_contributors_forbidden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"message": "The history or contributor list is too large to list contributors for this repository via the API.",
"documentation_url": "https://docs.github.com/rest/repos/repos#list-repository-contributors"
}
Loading