Skip to content

Commit

Permalink
Merge pull request #656 from esabouraud/feature-protectedbranchesoptions
Browse files Browse the repository at this point in the history
Issue 653 Add access control options to protected branch creation
  • Loading branch information
gpocentek committed Dec 8, 2018
2 parents 728f2dd + cebbbf6 commit 59e3e45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/gl_objects/protected_branches.rst
Expand Up @@ -35,6 +35,15 @@ Create a protected branch::
'push_access_level': gitlab.MAINTAINER_ACCESS
})

Create a protected branch with more granular access control::

p_branch = project.protectedbranches.create({
'name': '*-stable',
'allowed_to_push': [{"user_id": 99}, {"user_id": 98}],
'allowed_to_merge': [{"group_id": 653}],
'allowed_to_unprotect': [{"access_level": gitlab.MAINTAINER_ACCESS}]
})

Delete a protected branch::

project.protectedbranches.delete('*-stable')
Expand Down
5 changes: 4 additions & 1 deletion gitlab/v4/objects.py
Expand Up @@ -3117,7 +3117,10 @@ class ProjectProtectedBranchManager(NoUpdateMixin, RESTManager):
_path = '/projects/%(project_id)s/protected_branches'
_obj_cls = ProjectProtectedBranch
_from_parent_attrs = {'project_id': 'id'}
_create_attrs = (('name', ), ('push_access_level', 'merge_access_level'))
_create_attrs = (('name', ),
('push_access_level', 'merge_access_level',
'unprotect_access_level', 'allowed_to_push',
'allowed_to_merge', 'allowed_to_unprotect'))


class ProjectRunner(ObjectDeleteMixin, RESTObject):
Expand Down

0 comments on commit 59e3e45

Please sign in to comment.