diff options
Diffstat (limited to 'gitlab/v4/objects')
| -rw-r--r-- | gitlab/v4/objects/repositories.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/gitlab/v4/objects/repositories.py b/gitlab/v4/objects/repositories.py index b340e80..9c0cd9a 100644 --- a/gitlab/v4/objects/repositories.py +++ b/gitlab/v4/objects/repositories.py @@ -10,7 +10,7 @@ import requests import gitlab from gitlab import cli from gitlab import exceptions as exc -from gitlab import utils +from gitlab import types, utils if TYPE_CHECKING: # When running mypy we use these as the base classes @@ -246,6 +246,32 @@ class RepositoryMixin(_RestObjectBase): result, streamed, action, chunk_size, iterator=iterator ) + @cli.register_custom_action("Project", ("refs",)) + @exc.on_http_error(exc.GitlabGetError) + def repository_merge_base( + self, refs: List[str], **kwargs: Any + ) -> Union[Dict[str, Any], requests.Response]: + """Return a diff between two branches/commits. + + Args: + refs: The refs to find the common ancestor of. Multiple refs can be passed. + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabGetError: If the server failed to perform the request + + Returns: + The common ancestor commit (*not* a RESTObject) + """ + path = f"/projects/{self.encoded_id}/repository/merge_base" + query_data, _ = utils._transform_types( + data={"refs": refs}, + custom_types={"refs": types.ArrayAttribute}, + transform_data=True, + ) + return self.manager.gitlab.http_get(path, query_data=query_data, **kwargs) + @cli.register_custom_action("Project") @exc.on_http_error(exc.GitlabDeleteError) def delete_merged_branches(self, **kwargs: Any) -> None: |
