summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFayland Lam <fayland@gmail.com>2022-10-03 11:19:43 +0800
committerGitHub <noreply@github.com>2022-10-03 11:19:43 +0800
commit04073f420d4b9f85195bcde812bc1176398762a5 (patch)
treef74f6e81cb113fa5dddf0c4f31d04b31299e0c58
parentc443ea1c47b90b2eedaadd7db064683b7ce2de10 (diff)
parentfe328e1c3347e8a80f34b6057e539fc81a58b2df (diff)
Merge pull request #112 from jrmash/master
Add support for the branch protection api
-rw-r--r--lib/Net/GitHub/V3/Repos.pm41
1 files changed, 41 insertions, 0 deletions
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<http://developer.github.com/v3/repos/statistics/>
=back
+=head3 Branch Protection API
+
+L<https://docs.github.com/en/rest/branches/branch-protection>
+
+=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<Net::GitHub>