summaryrefslogtreecommitdiff
path: root/gitlab/v4
diff options
context:
space:
mode:
authorJohn Villalovos <john@sodarock.com>2022-10-31 03:24:27 -0700
committerGitHub <noreply@github.com>2022-10-31 10:24:27 +0000
commitbd82d745c8ea9ff6ff078a4c961a2d6e64a2f63c (patch)
tree823e263cad7af8dea77309e8ef69a3c23589e9d9 /gitlab/v4
parent29749660b9ca97dda1e7ad104d79266d5ed24d7b (diff)
downloadgitlab-bd82d745c8ea9ff6ff078a4c961a2d6e64a2f63c.tar.gz
fix: use POST method and return dict in `cancel_merge_when_pipeline_succeeds()` (#2350)
* Call was incorrectly using a `PUT` method when should have used a `POST` method. * Changed return type to a `dict` as GitLab only returns {'status': 'success'} on success. Since the function didn't work previously, this should not impact anyone. * Updated the test fixture `merge_request` to add ability to create a pipeline. * Added functional test for `mr.cancel_merge_when_pipeline_succeeds()` Fixes: #2349
Diffstat (limited to 'gitlab/v4')
-rw-r--r--gitlab/v4/objects/merge_requests.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/gitlab/v4/objects/merge_requests.py b/gitlab/v4/objects/merge_requests.py
index 2e1ab09..d4c3933 100644
--- a/gitlab/v4/objects/merge_requests.py
+++ b/gitlab/v4/objects/merge_requests.py
@@ -165,9 +165,7 @@ class ProjectMergeRequest(
@cli.register_custom_action("ProjectMergeRequest")
@exc.on_http_error(exc.GitlabMROnBuildSuccessError)
- def cancel_merge_when_pipeline_succeeds(
- self, **kwargs: Any
- ) -> "ProjectMergeRequest":
+ def cancel_merge_when_pipeline_succeeds(self, **kwargs: Any) -> Dict[str, str]:
"""Cancel merge when the pipeline succeeds.
Args:
@@ -179,17 +177,20 @@ class ProjectMergeRequest(
request
Returns:
- ProjectMergeRequest
+ dict of the parsed json returned by the server
"""
path = (
f"{self.manager.path}/{self.encoded_id}/cancel_merge_when_pipeline_succeeds"
)
- server_data = self.manager.gitlab.http_put(path, **kwargs)
+ server_data = self.manager.gitlab.http_post(path, **kwargs)
+ # 2022-10-30: The docs at
+ # https://docs.gitlab.com/ee/api/merge_requests.html#cancel-merge-when-pipeline-succeeds
+ # are incorrect in that the return value is actually just:
+ # {'status': 'success'} for a successful cancel.
if TYPE_CHECKING:
assert isinstance(server_data, dict)
- self._update_attrs(server_data)
- return ProjectMergeRequest(self.manager, server_data)
+ return server_data
@cli.register_custom_action("ProjectMergeRequest")
@exc.on_http_error(exc.GitlabListError)