From fe328e1c3347e8a80f34b6057e539fc81a58b2df Mon Sep 17 00:00:00 2001 From: "J.R. Mash" <2574997+jrmash@users.noreply.github.com> Date: Sun, 2 Oct 2022 19:54:40 -0700 Subject: Add support for the branch protection api --- lib/Net/GitHub/V3/Repos.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/Net/GitHub/V3/Repos.pm b/lib/Net/GitHub/V3/Repos.pm index fb39359..3346963 100644 --- a/lib/Net/GitHub/V3/Repos.pm +++ b/lib/Net/GitHub/V3/Repos.pm @@ -336,6 +336,10 @@ my %__methods = ( participation => { url => "/repos/%s/%s/stats/participation", method => 'GET'}, punch_card => { url => "/repos/%s/%s/stats/punch_card", method => 'GET'}, + # https://docs.github.com/en/rest/branches/branch-protection + branch_protection => { url => "/repos/%s/%s/branches/%s/protection", method => 'GET'}, + delete_branch_protection => { url => "/repos/%s/%s/branches/%s/protection", method => 'DELETE', check_status => 204 }, + update_branch_protection => { url => "/repos/%s/%s/branches/%s/protection", method => 'PUT', args => 1 }, ); __build_methods(__PACKAGE__, %__methods); @@ -996,6 +1000,43 @@ L =back +=head3 Branch Protection API + +L + +=over 4 + +=item branch_protection + + my $protection = $repos->branch_protection('fayland', 'perl-net-github', 'master'); + +=item delete_branch_protection + + $repos->delete_branch_protection('fayland', 'perl-net-github', 'master'); + +=item update_branch_protection + + $repos->update_branch_protection('fayland', 'perl-net-github', 'master', { + allow_deletions => \0, + allow_force_pushes => \0, + block_creations => \1, + enforce_admins => \1, + required_conversation_resolution => \1, + required_linear_history => \0, + required_pull_request_reviews => { + dismiss_stale_reviews => \1, + require_code_owner_reviews => \1, + required_approving_review_count => 2, + }, + required_status_checks => { + strict => \1, + contexts => [] + }, + restrictions => undef, + }); + +=back + =head1 AUTHOR & COPYRIGHT & LICENSE Refer L -- cgit v1.2.3