diff --git a/marge/batch_job.py b/marge/batch_job.py index faf6b55f..404a5f33 100644 --- a/marge/batch_job.py +++ b/marge/batch_job.py @@ -1,6 +1,7 @@ # pylint: disable=too-many-branches,too-many-statements,arguments-differ import logging as log from time import sleep +from requests.utils import quote from . import git from . import gitlab @@ -9,6 +10,8 @@ from .merge_request import MergeRequest from .pipeline import Pipeline +DELETE = gitlab.DELETE + class CannotBatch(Exception): pass @@ -195,6 +198,16 @@ def accept_mr( for pipeline in pipelines: pipeline.cancel() + if merge_request.force_remove_source_branch: + self._api.call( + DELETE( + 'projects/{}/repository/branches/{}'.format( + merge_request.source_project_id, + quote(merge_request.source_branch, safe='') + ) + ) + ) + return final_sha def execute(self):