Skip to content

Commit

Permalink
fix: remove default arguments for mergerequests.merge()
Browse files Browse the repository at this point in the history
The arguments `should_remove_source_branch` and
`merge_when_pipeline_succeeds` are optional arguments. We should not
be setting any default value for them.

https://docs.gitlab.com/ee/api/merge_requests.html#accept-mr

Closes: #1750
  • Loading branch information
JohnVillalovos committed Jan 8, 2022
1 parent 22a1516 commit 8e589c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions gitlab/v4/objects/merge_requests.py
Expand Up @@ -358,8 +358,8 @@ def merge_ref(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
def merge(
self,
merge_commit_message: Optional[str] = None,
should_remove_source_branch: bool = False,
merge_when_pipeline_succeeds: bool = False,
should_remove_source_branch: Optional[bool] = None,
merge_when_pipeline_succeeds: Optional[bool] = None,
**kwargs: Any,
) -> Dict[str, Any]:
"""Accept the merge request.
Expand All @@ -382,8 +382,8 @@ def merge(
data["merge_commit_message"] = merge_commit_message
if should_remove_source_branch is not None:
data["should_remove_source_branch"] = should_remove_source_branch
if merge_when_pipeline_succeeds:
data["merge_when_pipeline_succeeds"] = True
if merge_when_pipeline_succeeds is not None:
data["merge_when_pipeline_succeeds"] = merge_when_pipeline_succeeds

server_data = self.manager.gitlab.http_put(path, post_data=data, **kwargs)
if TYPE_CHECKING:
Expand Down
4 changes: 3 additions & 1 deletion tests/functional/api/test_merge_requests.py
Expand Up @@ -170,7 +170,9 @@ def test_merge_request_large_commit_message(
merge_commit_message = "large_message\r\n" * 1_000
assert len(merge_commit_message) > 10_000

mr.merge(merge_commit_message=merge_commit_message)
mr.merge(
merge_commit_message=merge_commit_message, should_remove_source_branch=False
)

result = wait_for_sidekiq(timeout=60)
assert result is True, "sidekiq process should have terminated but did not"
Expand Down

0 comments on commit 8e589c4

Please sign in to comment.