Skip to content

Commit

Permalink
Update API for remove source branch on merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Viatorus authored and JaimeLennox committed Jul 10, 2019
1 parent d8e0b15 commit f274cef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion marge/merge_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def accept(self, remove_branch=False, sha=None):
return self._api.call(PUT(
'/projects/{0.project_id}/merge_requests/{0.iid}/merge'.format(self),
dict(
remove_source_branch=remove_branch,
should_remove_source_branch=remove_branch,
merge_when_pipeline_succeeds=True,
sha=sha or self.sha, # if provided, ensures what is merged is what we want (or fails)
),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_merge_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_accept(self):
'/projects/1234/merge_requests/54/merge',
dict(
merge_when_pipeline_succeeds=True,
remove_source_branch=boolean,
should_remove_source_branch=boolean,
sha='badc0de',
)
))
Expand All @@ -169,7 +169,7 @@ def test_accept(self):
'/projects/1234/merge_requests/54/merge',
dict(
merge_when_pipeline_succeeds=True,
remove_source_branch=False,
should_remove_source_branch=False,
sha='g00dc0de',
)
))
Expand Down
16 changes: 8 additions & 8 deletions tests/test_single_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=self.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Ok({}),
from_state=['passed', 'skipped'], to_state='merged',
Expand Down Expand Up @@ -519,7 +519,7 @@ def push_effects(remote_url, remote_branch, old_sha, new_sha):
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(
sha=first_rewritten_sha,
remove_source_branch=True,
should_remove_source_branch=True,
merge_when_pipeline_succeeds=True,
),
),
Expand Down Expand Up @@ -572,7 +572,7 @@ def test_handles_races_for_merging(self, mocks):
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Error(marge.gitlab.NotFound(404, {'message': '404 Branch Not Found'})),
from_state='passed', to_state='someone_else_merged',
Expand All @@ -591,7 +591,7 @@ def test_handles_request_becoming_wip_after_push(self, mocks):
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Error(marge.gitlab.MethodNotAllowed(405, {'message': '405 Method Not Allowed'})),
from_state='passed', to_state='now_is_wip',
Expand All @@ -612,7 +612,7 @@ def test_guesses_git_hook_error_on_merge_refusal(self, mocks):
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Error(marge.gitlab.MethodNotAllowed(405, {'message': '405 Method Not Allowed'})),
from_state='passed', to_state='rejected_by_git_hook',
Expand All @@ -636,7 +636,7 @@ def test_assumes_unresolved_discussions_on_merge_refusal(self, mocks):
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Error(marge.gitlab.MethodNotAllowed(405, {'message': '405 Method Not Allowed'})),
from_state='passed', to_state='unresolved_discussions',
Expand All @@ -661,7 +661,7 @@ def test_discovers_if_someone_closed_the_merge_request(self, mocks):
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Error(marge.gitlab.MethodNotAllowed(405, {'message': '405 Method Not Allowed'})),
from_state='passed', to_state='oops_someone_closed_it',
Expand All @@ -682,7 +682,7 @@ def test_tells_explicitly_that_gitlab_refused_to_merge(self, mocks):
api.add_transition(
PUT(
'/projects/1234/merge_requests/{iid}/merge'.format(iid=mocklab.merge_request_info['iid']),
dict(sha=rewritten_sha, remove_source_branch=True, merge_when_pipeline_succeeds=True),
dict(sha=rewritten_sha, should_remove_source_branch=True, merge_when_pipeline_succeeds=True),
),
Error(marge.gitlab.MethodNotAllowed(405, {'message': '405 Method Not Allowed'})),
from_state='passed', to_state='rejected_for_mysterious_reasons',
Expand Down

0 comments on commit f274cef

Please sign in to comment.