Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9656a16

Browse files
nejchJohnVillalovos
authored andcommitted
refactor(objects): remove deprecated branch protect methods
BREAKING CHANGE: remove deprecated branch protect methods in favor ofthe more complete protected branches API.
1 parentc59fbdb commit9656a16

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-
fromgitlabimportcli
2-
fromgitlabimportexceptionsasexc
31
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
42
fromgitlab.mixinsimportNoUpdateMixin,ObjectDeleteMixin
53

@@ -14,50 +12,6 @@
1412
classProjectBranch(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-
defprotect(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-
defunprotect(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
classProjectBranchManager(NoUpdateMixin,RESTManager):
6317
_path="/projects/%(project_id)s/repository/branches"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp