Skip to content

Commit 6744d11

Browse files
author
shiro
authored
fix(github_nulls): Better handling of Nulls in GitHub API (#39)
* fix(branch_protections.py): Handle null GitHub Elements Corrects issue where GitHub repo currently contains no elements, but config file does * fix(branch_protections.py): Handle null GitHub Elements
1 parent 4d4c44f commit 6744d11

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

repo_manager/github/branch_protections.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,21 +285,27 @@ def check_repo_branch_protections(
285285
diff_option(
286286
"required_approving_review_count",
287287
config_bp.protection.pr_options.required_approving_review_count,
288-
this_protection.required_pull_request_reviews.required_approving_review_count,
288+
## Had issues when the YAML defines this but the Repo has none (e.g. it's null in the cloud)
289+
None if (this_protection.required_pull_request_reviews is None) else \
290+
this_protection.required_pull_request_reviews.required_approving_review_count,
289291
)
290292
)
291293
diffs.append(
292294
diff_option(
293295
"dismiss_stale_reviews",
294296
config_bp.protection.pr_options.dismiss_stale_reviews,
295-
this_protection.required_pull_request_reviews.dismiss_stale_reviews,
297+
## Had issues when the YAML defines this but the Repo has none (e.g. it's null in the cloud)
298+
None if (this_protection.required_pull_request_reviews is None) else \
299+
this_protection.required_pull_request_reviews.dismiss_stale_reviews,
296300
)
297301
)
298302
diffs.append(
299303
diff_option(
300304
"require_code_owner_reviews",
301305
config_bp.protection.pr_options.require_code_owner_reviews,
302-
this_protection.required_pull_request_reviews.require_code_owner_reviews,
306+
## Had issues when the YAML defines this but the Repo has none (e.g. it's null in the cloud)
307+
None if (this_protection.required_pull_request_reviews is None) else \
308+
this_protection.required_pull_request_reviews.require_code_owner_reviews,
303309
)
304310
)
305311
# for now, not checking dismissal options. Will note that in the docs

0 commit comments

Comments
 (0)