Skip to content

Commit 9656a16

Browse files
nejchJohnVillalovos
authored andcommitted
refactor(objects): remove deprecated branch protect methods
BREAKING CHANGE: remove deprecated branch protect methods in favor of the more complete protected branches API.
1 parent c59fbdb commit 9656a16

File tree

2 files changed

+2
-61
lines changed

2 files changed

+2
-61
lines changed

docs/gl_objects/branches.rst

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,8 @@ Delete a repository branch::
3535
# or
3636
branch.delete()
3737

38-
Protect/unprotect a repository branch::
39-
40-
branch.protect()
41-
branch.unprotect()
42-
43-
.. note::
44-
45-
By default, developers are not authorized to push or merge into protected
46-
branches. This can be changed by passing ``developers_can_push`` or
47-
``developers_can_merge``:
48-
49-
.. code-block:: python
50-
51-
branch.protect(developers_can_push=True, developers_can_merge=True)
52-
5338
Delete the merged branches for a project::
5439

5540
project.delete_merged_branches()
41+
42+
To manage protected branches, see :doc:`/gl_objects/protected_branches`.

gitlab/v4/objects/branches.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from gitlab import cli
2-
from gitlab import exceptions as exc
31
from gitlab.base import RequiredOptional, RESTManager, RESTObject
42
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin
53

@@ -14,50 +12,6 @@
1412
class ProjectBranch(ObjectDeleteMixin, RESTObject):
1513
_id_attr = "name"
1614

17-
@cli.register_custom_action(
18-
"ProjectBranch", tuple(), ("developers_can_push", "developers_can_merge")
19-
)
20-
@exc.on_http_error(exc.GitlabProtectError)
21-
def protect(self, developers_can_push=False, developers_can_merge=False, **kwargs):
22-
"""Protect the branch.
23-
24-
Args:
25-
developers_can_push (bool): Set to True if developers are allowed
26-
to push to the branch
27-
developers_can_merge (bool): Set to True if developers are allowed
28-
to merge to the branch
29-
**kwargs: Extra options to send to the server (e.g. sudo)
30-
31-
Raises:
32-
GitlabAuthenticationError: If authentication is not correct
33-
GitlabProtectError: If the branch could not be protected
34-
"""
35-
id = self.get_id().replace("/", "%2F")
36-
path = "%s/%s/protect" % (self.manager.path, id)
37-
post_data = {
38-
"developers_can_push": developers_can_push,
39-
"developers_can_merge": developers_can_merge,
40-
}
41-
self.manager.gitlab.http_put(path, post_data=post_data, **kwargs)
42-
self._attrs["protected"] = True
43-
44-
@cli.register_custom_action("ProjectBranch")
45-
@exc.on_http_error(exc.GitlabProtectError)
46-
def unprotect(self, **kwargs):
47-
"""Unprotect the branch.
48-
49-
Args:
50-
**kwargs: Extra options to send to the server (e.g. sudo)
51-
52-
Raises:
53-
GitlabAuthenticationError: If authentication is not correct
54-
GitlabProtectError: If the branch could not be unprotected
55-
"""
56-
id = self.get_id().replace("/", "%2F")
57-
path = "%s/%s/unprotect" % (self.manager.path, id)
58-
self.manager.gitlab.http_put(path, **kwargs)
59-
self._attrs["protected"] = False
60-
6115

6216
class ProjectBranchManager(NoUpdateMixin, RESTManager):
6317
_path = "/projects/%(project_id)s/repository/branches"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy