Skip to content

Commit b1cf227

Browse files
committed
Make RequireLastPushApproval field optional
Signed-off-by: Daniel Liao <10663736+liaodaniel@users.noreply.github.com>
1 parent 66ca34f commit b1cf227

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ type PullRequestReviewsEnforcementRequest struct {
10651065
// Valid values are 1-6.
10661066
RequiredApprovingReviewCount int `json:"required_approving_review_count"`
10671067
// RequireLastPushApproval specifies whether the last pusher to a pull request branch can approve it.
1068-
RequireLastPushApproval bool `json:"require_last_push_approval"`
1068+
RequireLastPushApproval *bool `json:"require_last_push_approval,omitempty"`
10691069
}
10701070

10711071
// PullRequestReviewsEnforcementUpdate represents request to patch the pull request review

github/repos_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ func TestRepositoriesService_UpdateBranchProtection_RequireLastPushApproval(t *t
17111711

17121712
input := &ProtectionRequest{
17131713
RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
1714-
RequireLastPushApproval: true,
1714+
RequireLastPushApproval: Bool(true),
17151715
},
17161716
}
17171717

@@ -2581,7 +2581,7 @@ func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctio
25812581
t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
25822582
}
25832583

2584-
want := `{"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0,"require_last_push_approval":false}`
2584+
want := `{"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}`
25852585
if want != string(got) {
25862586
t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
25872587
}
@@ -2595,7 +2595,7 @@ func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctio
25952595
t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
25962596
}
25972597

2598-
want = `{"dismissal_restrictions":{},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0,"require_last_push_approval":false}`
2598+
want = `{"dismissal_restrictions":{},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}`
25992599
if want != string(got) {
26002600
t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
26012601
}
@@ -2606,7 +2606,7 @@ func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctio
26062606
Teams: &[]string{},
26072607
Apps: &[]string{},
26082608
},
2609-
RequireLastPushApproval: true,
2609+
RequireLastPushApproval: Bool(true),
26102610
}
26112611

26122612
got, err = json.Marshal(req)

0 commit comments

Comments
 (0)