diff --git a/marge/merge_request.py b/marge/merge_request.py index 63523514..eb875c00 100644 --- a/marge/merge_request.py +++ b/marge/merge_request.py @@ -191,13 +191,14 @@ def rebase(self): raise TimeoutError('Waiting for merge request to be rebased by GitLab') - def accept(self, remove_branch=False, sha=None, merge_when_pipeline_succeeds=True): + def accept(self, remove_branch=False, sha=None, merge_when_pipeline_succeeds=True, auto_squash=False): return self._api.call(PUT( '/projects/{0.project_id}/merge_requests/{0.iid}/merge'.format(self), dict( should_remove_source_branch=remove_branch, merge_when_pipeline_succeeds=merge_when_pipeline_succeeds, sha=sha or self.sha, # if provided, ensures what is merged is what we want (or fails) + squash=auto_squash ), )) diff --git a/marge/single_merge_job.py b/marge/single_merge_job.py index c929f6e3..9d4850f0 100644 --- a/marge/single_merge_job.py +++ b/marge/single_merge_job.py @@ -86,6 +86,7 @@ def update_merge_request_and_accept(self, approvals): remove_branch=merge_request.force_remove_source_branch, sha=actual_sha, merge_when_pipeline_succeeds=bool(target_project.only_allow_merge_if_pipeline_succeeds), + auto_squash=merge_request.squash ) log.info('merge_request.accept result: %s', ret) except gitlab.NotAcceptable as err: