Skip to content

Commit 671ce96

Browse files
committed
validate_contents: correctly handle empty repos
1 parent 3b825aa commit 671ce96

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

adabot/lib/circuitpython_library_validators.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,23 @@ def validate_contents(self, repo):
442442
return []
443443

444444
content_list = github.get("/repos/" + repo["full_name"] + "/contents/")
445-
# Empty repos return an object with a "message" that the repo is empty.
446-
if not content_list.ok or "message" in content_list.json():
447-
if not self.validate_contents_quiet:
448-
return [ERROR_UNABLE_PULL_REPO_CONTENTS]
449-
return []
445+
empty_repo = False
446+
if not content_list.ok:
447+
# Empty repos return:
448+
# - a 404 status code
449+
# - a "message" that the repo is empty.
450+
if "message" in content_list.json():
451+
if "empty" in content_list.json()["message"]:
452+
empty_repo = True
453+
if not empty_repo:
454+
if not self.validate_contents_quiet:
455+
return [ERROR_UNABLE_PULL_REPO_CONTENTS]
456+
return []
450457

451458
content_list = content_list.json()
452459
files = []
453460
# an empty repo will return a 'message'
454-
if "message" not in content_list:
461+
if not empty_repo:
455462
files = [x["name"] for x in content_list]
456463

457464
# ignore new/in-work repos, which should have less than 8 files:

0 commit comments

Comments
 (0)