From 0892dbd2edfd6b3fae7ef9e1fe78674366a1792e Mon Sep 17 00:00:00 2001 From: noamd-legit <74864790+noamd-legit@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:35:03 +0200 Subject: [PATCH 1/4] get 'require_last_push_approval' field --- github/repos.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github/repos.go b/github/repos.go index e12cff0837..a0577bf193 100644 --- a/github/repos.go +++ b/github/repos.go @@ -1028,6 +1028,8 @@ type PullRequestReviewsEnforcement struct { // RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged. // Valid values are 1-6. RequiredApprovingReviewCount int `json:"required_approving_review_count"` + // RequireLastPushApproval specifies whether the last pusher to a pull request branch can approve it. + RequireLastPushApproval bool `json:"require_last_push_approval"` } // PullRequestReviewsEnforcementRequest represents request to set the pull request review From 9b2d11e6276972bb123538e0e0ad24c997ac1cf1 Mon Sep 17 00:00:00 2001 From: noamd-legit <74864790+noamd-legit@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:01:41 +0200 Subject: [PATCH 2/4] added 'require_last_push_approval' for the PullRequestReviewsEnforcementUpdate struct --- github/repos.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github/repos.go b/github/repos.go index a0577bf193..69584a385a 100644 --- a/github/repos.go +++ b/github/repos.go @@ -1066,6 +1066,8 @@ type PullRequestReviewsEnforcementUpdate struct { // RequiredApprovingReviewCount specifies the number of approvals required before the pull request can be merged. // Valid values are 1 - 6 or 0 to not require reviewers. RequiredApprovingReviewCount int `json:"required_approving_review_count"` + // RequireLastPushApproval specifies whether the last pusher to a pull request branch can approve it. + RequireLastPushApproval *bool `json:"require_last_push_approval"` } // RequireLinearHistory represents the configuration to enforce branches with no merge commit. From 8f8d34c15b5f0bfa6792bee58bf7ad8f851a8265 Mon Sep 17 00:00:00 2001 From: noamd-legit <74864790+noamd-legit@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:42:13 +0200 Subject: [PATCH 3/4] Update github/repos.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 69584a385a..9364e8d69f 100644 --- a/github/repos.go +++ b/github/repos.go @@ -1067,7 +1067,7 @@ type PullRequestReviewsEnforcementUpdate struct { // Valid values are 1 - 6 or 0 to not require reviewers. RequiredApprovingReviewCount int `json:"required_approving_review_count"` // RequireLastPushApproval specifies whether the last pusher to a pull request branch can approve it. - RequireLastPushApproval *bool `json:"require_last_push_approval"` + RequireLastPushApproval *bool `json:"require_last_push_approval,omitempty"` } // RequireLinearHistory represents the configuration to enforce branches with no merge commit. From 8cc248d05802f3b91a98cbe282ff3efd1c1337f9 Mon Sep 17 00:00:00 2001 From: noamd Date: Thu, 17 Nov 2022 15:51:18 +0200 Subject: [PATCH 4/4] go generate --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index a01036de23..0d9db6ff89 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13670,6 +13670,14 @@ func (p *PullRequestReviewsEnforcementUpdate) GetRequireCodeOwnerReviews() bool return *p.RequireCodeOwnerReviews } +// GetRequireLastPushApproval returns the RequireLastPushApproval field if it's non-nil, zero value otherwise. +func (p *PullRequestReviewsEnforcementUpdate) GetRequireLastPushApproval() bool { + if p == nil || p.RequireLastPushApproval == nil { + return false + } + return *p.RequireLastPushApproval +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (p *PullRequestReviewThreadEvent) GetAction() string { if p == nil || p.Action == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 78e862892f..bd2b95dea8 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -15873,6 +15873,16 @@ func TestPullRequestReviewsEnforcementUpdate_GetRequireCodeOwnerReviews(tt *test p.GetRequireCodeOwnerReviews() } +func TestPullRequestReviewsEnforcementUpdate_GetRequireLastPushApproval(tt *testing.T) { + var zeroValue bool + p := &PullRequestReviewsEnforcementUpdate{RequireLastPushApproval: &zeroValue} + p.GetRequireLastPushApproval() + p = &PullRequestReviewsEnforcementUpdate{} + p.GetRequireLastPushApproval() + p = nil + p.GetRequireLastPushApproval() +} + func TestPullRequestReviewThreadEvent_GetAction(tt *testing.T) { var zeroValue string p := &PullRequestReviewThreadEvent{Action: &zeroValue}