summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-05-27 18:58:47 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-05-27 18:58:47 +0200
commit590ea0da7e5617c42e705c62370d6e94ff46ea74 (patch)
tree5d12ebf09390b9be68981fa7bb79f0907af85219
parent4461139b4ace84368ccd595a459d51f9fd81b7a1 (diff)
downloadgitlab-590ea0da7e5617c42e705c62370d6e94ff46ea74.tar.gz
Add support for merged branches deletion
-rw-r--r--docs/gl_objects/branches.rst4
-rw-r--r--gitlab/v4/objects.py15
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/gl_objects/branches.rst b/docs/gl_objects/branches.rst
index 15f2b5c..8860ff9 100644
--- a/docs/gl_objects/branches.rst
+++ b/docs/gl_objects/branches.rst
@@ -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()
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 3372d47..2c96e74 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -2812,6 +2812,21 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
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):
"""Star a project.