Skip to content

Commit 1c8e525

Browse files
committed
fix(github): follow check behavior of pygithub
1 parent 91be637 commit 1c8e525

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,26 @@ def get_github_commits(self):
313313
# Get commits
314314
try:
315315
commits = self.repo.get_commits(sha=self.branch)
316+
if commits.totalCount == 0:
317+
print('[WARN] No commits found on branch', self.branch)
318+
message = {}
319+
message['message'] = 'Not Found'
320+
message[
321+
'documentation_url'] = 'https://docs.github.com/rest/commits/commits#list-commits'
322+
raise github.GithubException.UnknownObjectException(
323+
404, message)
316324
return commits
317325
except github.GithubException as e:
318326
if e.status == 404:
319327
commits = self.repo.get_commits()
328+
if commits.totalCount == 0:
329+
print('[WARN] No commits found on default branch')
330+
message = {}
331+
message['message'] = 'Not Found'
332+
message[
333+
'documentation_url'] = 'https://docs.github.com/rest/commits/commits#list-commits'
334+
raise github.GithubException.UnknownObjectException(
335+
404, message)
320336
return commits
321337
else:
322338
raise github.GithubException(e.status, e.data)

0 commit comments

Comments
 (0)