8000 Update Branch.protect such that its arguments are optional. · degustaf/github3.py@1b7ea5a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b7ea5a

Browse files
committed
Update Branch.protect such that its arguments are optional.
1 parent 4bd0237 commit 1b7ea5a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

github3/repos/branch.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@ def _update_attributes(self, branch):
3232
def _repr(self):
3333
return '<Repository Branch [{0}]>'.format(self.name)
3434

35-
def protect(self, enforcement, status_checks):
35+
def protect(self, enforcement=None, status_checks=None):
3636
"""Enable force push protection and configure status check enforcement.
3737
3838
See: http://git.io/v4Gvu
3939
40-
:param str enforcement: (required), Specifies the enforcement level of
40+
:param str enforcement: (optional), Specifies the enforcement level of
4141
the status checks. Must be one of 'off', 'non_admins', or
42-
'everyone'.
43-
:param list status_checks: (required), An iterable of strings naming
44-
status checks that must pass before merging.
42+
'everyone'. Use `None` or omit to use the already associated value.
43+
:param list status_checks: (optional), An list of strings naming
44+
status checks that must pass before merging. Use `None` or omit to
45+
use the already associated value.
4546
"""
47+
previous_values = self.protection['required_status_checks']
48+
if enforcement is None:
49+
enforcement = previous_values['enforcement_level']
50+
if status_checks is None:
51+
status_checks = previous_values['contexts']
52+
4653
edit = {'protection': {'enabled': True, 'required_status_checks': {
4754
'enforcement_level': enforcement, 'contexts': status_checks}}}
4855
json = self._json(self._patch(self.links['self'], data=dumps(edit),

0 commit comments

Comments
 (0)
0