Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove source branches in batch jobs if necessary #355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions marge/batch_job.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +10,8 @@
from .merge_request import MergeRequest
from .pipeline import Pipeline

DELETE = gitlab.DELETE


class CannotBatch(Exception):
pass
Expand Down Expand Up @@ -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):
Expand Down