Skip to content

Commit

Permalink
Add support for merged branches deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed May 27, 2018
1 parent 4461139 commit 590ea0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/gl_objects/branches.rst
Expand Up @@ -49,3 +49,7 @@ Protect/unprotect a repository branch::
.. code-block:: python
branch.protect(developers_can_push=True, developers_can_merge=True)
Delete the merged branches for a project::

project.delete_merged_branches()
15 changes: 15 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -2811,6 +2811,21 @@ def delete_fork_relation(self, **kwargs):
path = '/projects/%s/fork' % self.get_id()
self.manager.gitlab.http_delete(path, **kwargs)

@cli.register_custom_action('Project')
@exc.on_http_error(exc.GitlabDeleteError)
def delete_merged_branches(self, **kwargs):
"""Delete merged branches.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server failed to perform the request
"""
path = '/projects/%s/repository/merged_branches' % self.get_id()
self.manager.gitlab.http_delete(path, **kwargs)

@cli.register_custom_action('Project')
@exc.on_http_error(exc.GitlabCreateError)
def star(self, **kwargs):
Expand Down

0 comments on commit 590ea0d

Please sign in to comment.