Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cebbbf6

Browse filesBrowse files
committed
Add access control options to protected branch creation
1 parent 728f2dd commit cebbbf6
Copy full SHA for cebbbf6

File tree

Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed
Open diff view settings
Collapse file

‎docs/gl_objects/protected_branches.rst‎

Copy file name to clipboardExpand all lines: docs/gl_objects/protected_branches.rst
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ Create a protected branch::
3535
'push_access_level': gitlab.MAINTAINER_ACCESS
3636
})
3737

38+
Create a protected branch with more granular access control::
39+
40+
p_branch = project.protectedbranches.create({
41+
'name': '*-stable',
42+
'allowed_to_push': [{"user_id": 99}, {"user_id": 98}],
43+
'allowed_to_merge': [{"group_id": 653}],
44+
'allowed_to_unprotect': [{"access_level": gitlab.MAINTAINER_ACCESS}]
45+
})
46+
3847
Delete a protected branch::
3948

4049
project.protectedbranches.delete('*-stable')
Collapse file

‎gitlab/v4/objects.py‎

Copy file name to clipboardExpand all lines: gitlab/v4/objects.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,10 @@ class ProjectProtectedBranchManager(NoUpdateMixin, RESTManager):
31173117
_path = '/projects/%(project_id)s/protected_branches'
31183118
_obj_cls = ProjectProtectedBranch
31193119
_from_parent_attrs = {'project_id': 'id'}
3120-
_create_attrs = (('name', ), ('push_access_level', 'merge_access_level'))
3120+
_create_attrs = (('name', ),
3121+
('push_access_level', 'merge_access_level',
3122+
'unprotect_access_level', 'allowed_to_push',
3123+
'allowed_to_merge', 'allowed_to_unprotect'))
31213124

31223125

31233126
class ProjectRunner(ObjectDeleteMixin, RESTObject):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.