Skip to content

Commit

Permalink
Handle search API error
Browse files Browse the repository at this point in the history
  • Loading branch information
saadmk11 committed Sep 3, 2020
1 parent 6ebed89 commit f444f84
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions scripts/changelog-ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,27 @@ def _get_pull_requests_after_last_release(self):

response = requests.get(url)

response_data = response.json()

if response_data['total_count'] > 0:
if response.status_code == 200:
response_data = response.json()

for item in response_data['items']:
data = {
'title': item['title'],
'number': item['number'],
'url': item['html_url']
}
items.append(data)
if response_data['total_count'] > 0:
for item in response_data['items']:
data = {
'title': item['title'],
'number': item['number'],
'url': item['html_url']
}
items.append(data)
else:
logger.warning(
'There was no pull request made on %s after last release.',
self.repository
)
else:
logger.error(
'GitHub API returned error response for %s, status code: %s',
self.repository, response.status_code
)

return items

Expand All @@ -116,8 +126,8 @@ def write_changelog(self):

items = self._get_pull_requests_after_last_release()

# exit the function if there is not pull request found
if not items:
print('There was no pull request made after last release.')
return

file_mode = self._get_file_mode()
Expand Down

0 comments on commit f444f84

Please sign in to comment.