Skip to content

Commit 590ea0d

Browse files
author
Gauvain Pocentek
committed
Add support for merged branches deletion
1 parent 4461139 commit 590ea0d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/gl_objects/branches.rst

+4
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ Protect/unprotect a repository branch::
4949
.. code-block:: python
5050
5151
branch.protect(developers_can_push=True, developers_can_merge=True)
52+
53+
Delete the merged branches for a project::
54+
55+
project.delete_merged_branches()

gitlab/v4/objects.py

+15
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,21 @@ def delete_fork_relation(self, **kwargs):
28112811
path = '/projects/%s/fork' % self.get_id()
28122812
self.manager.gitlab.http_delete(path, **kwargs)
28132813

2814+
@cli.register_custom_action('Project')
2815+
@exc.on_http_error(exc.GitlabDeleteError)
2816+
def delete_merged_branches(self, **kwargs):
2817+
"""Delete merged branches.
2818+
2819+
Args:
2820+
**kwargs: Extra options to send to the server (e.g. sudo)
2821+
2822+
Raises:
2823+
GitlabAuthenticationError: If authentication is not correct
2824+
GitlabDeleteError: If the server failed to perform the request
2825+
"""
2826+
path = '/projects/%s/repository/merged_branches' % self.get_id()
2827+
self.manager.gitlab.http_delete(path, **kwargs)
2828+
28142829
@cli.register_custom_action('Project')
28152830
@exc.on_http_error(exc.GitlabCreateError)
28162831
def star(self, **kwargs):

0 commit comments

Comments
 (0)