Skip to content

fix: change to http_list for some ProjectCommit methods #1809

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

Merged
merged 1 commit into from
Jan 8, 2022
Merged
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
19 changes: 11 additions & 8 deletions gitlab/v4/objects/commits.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union
from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING, Union

import requests

import gitlab
from gitlab import cli
from gitlab import exceptions as exc
from gitlab.base import RequiredOptional, RESTManager, RESTObject
Expand All @@ -28,7 +29,7 @@ class ProjectCommit(RESTObject):

@cli.register_custom_action("ProjectCommit")
@exc.on_http_error(exc.GitlabGetError)
def diff(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
def diff(self, **kwargs: Any) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]:
"""Generate the commit diff.

Args:
Expand All @@ -42,7 +43,7 @@ def diff(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
The changes done in this commit
"""
path = f"{self.manager.path}/{self.get_id()}/diff"
return self.manager.gitlab.http_get(path, **kwargs)
return self.manager.gitlab.http_list(path, **kwargs)

@cli.register_custom_action("ProjectCommit", ("branch",))
@exc.on_http_error(exc.GitlabCherryPickError)
Expand All @@ -65,7 +66,7 @@ def cherry_pick(self, branch: str, **kwargs: Any) -> None:
@exc.on_http_error(exc.GitlabGetError)
def refs(
self, type: str = "all", **kwargs: Any
) -> Union[Dict[str, Any], requests.Response]:
) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]:
"""List the references the commit is pushed to.

Args:
Expand All @@ -80,12 +81,14 @@ def refs(
The references the commit is pushed to.
"""
path = f"{self.manager.path}/{self.get_id()}/refs"
data = {"type": type}
return self.manager.gitlab.http_get(path, query_data=data, **kwargs)
query_data = {"type": type}
return self.manager.gitlab.http_list(path, query_data=query_data, **kwargs)

@cli.register_custom_action("ProjectCommit")
@exc.on_http_error(exc.GitlabGetError)
def merge_requests(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
def merge_requests(
self, **kwargs: Any
) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]:
"""List the merge requests related to the commit.

Args:
Expand All @@ -99,7 +102,7 @@ def merge_requests(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Respon
The merge requests related to the commit.
"""
path = f"{self.manager.path}/{self.get_id()}/merge_requests"
return self.manager.gitlab.http_get(path, **kwargs)
return self.manager.gitlab.http_list(path, **kwargs)

@cli.register_custom_action("ProjectCommit", ("branch",))
@exc.on_http_error(exc.GitlabRevertError)
Expand Down