From ceca18035b804bf55b41e0a6d9e073cdd84ae7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Thu, 27 Mar 2025 14:22:09 +0100 Subject: [PATCH 1/2] Add support for require_last_push_approval flag on branch protection --- asfyaml/feature/github/__init__.py | 1 + asfyaml/feature/github/branch_protection.py | 1 + 2 files changed, 2 insertions(+) diff --git a/asfyaml/feature/github/__init__.py b/asfyaml/feature/github/__init__.py index e980383..5b39eb0 100644 --- a/asfyaml/feature/github/__init__.py +++ b/asfyaml/feature/github/__init__.py @@ -111,6 +111,7 @@ class ASFGitHubFeature(ASFYamlFeature, name="github"): { strictyaml.Optional("dismiss_stale_reviews", default=False): strictyaml.Bool(), strictyaml.Optional("require_code_owner_reviews", default=False): strictyaml.Bool(), + strictyaml.Optional("require_last_push_approval", default=False): strictyaml.Bool(), strictyaml.Optional("required_approving_review_count", default=0): strictyaml.Int(), } ), diff --git a/asfyaml/feature/github/branch_protection.py b/asfyaml/feature/github/branch_protection.py index 32c6be7..3e77a8c 100644 --- a/asfyaml/feature/github/branch_protection.py +++ b/asfyaml/feature/github/branch_protection.py @@ -255,6 +255,7 @@ def branch_protection(self: ASFGitHubFeature): required_approving_review_count=required_approving_review_count, dismiss_stale_reviews=dismiss_stale_reviews, require_code_owner_reviews=require_code_owner_reviews, + require_last_push_approval=require_last_push_approval, strict=require_strict, checks=required_checks, # type: ignore ) From ecb2c5986ef89251c99e640b4cbc1bbcac8c893d Mon Sep 17 00:00:00 2001 From: Daniel Gruno Date: Thu, 27 Mar 2025 14:26:28 +0100 Subject: [PATCH 2/2] Update branch_protection.py, set the push approval var --- asfyaml/feature/github/branch_protection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asfyaml/feature/github/branch_protection.py b/asfyaml/feature/github/branch_protection.py index 3e77a8c..932bfa3 100644 --- a/asfyaml/feature/github/branch_protection.py +++ b/asfyaml/feature/github/branch_protection.py @@ -146,10 +146,12 @@ def branch_protection(self: ASFGitHubFeature): required_approving_review_count = required_pull_request_reviews.get("required_approving_review_count", 0) require_code_owner_reviews = required_pull_request_reviews.get("require_code_owner_reviews") dismiss_stale_reviews = required_pull_request_reviews.get("dismiss_stale_reviews", NotSet) + require_last_push_approval = required_pull_request_reviews.get("require_last_push_approval", NotSet) else: required_pull_request_reviews = NotSet required_approving_review_count = NotSet dismiss_stale_reviews = NotSet + require_last_push_approval = NotSet require_code_owner_reviews = NotSet required_checks: Opt[list[tuple[str, int]]]