Skip to content
Closed
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
20 changes: 20 additions & 0 deletions gitlab/v4/objects/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ def repository_compare(self, from_, to, **kwargs):
query_data = {"from": from_, "to": to}
return self.manager.gitlab.http_get(path, query_data=query_data, **kwargs)

@cli.register_custom_action("Project", ("from_", "to"))
@exc.on_http_error(exc.GitlabGetError)
def merge_base(self, from_, to, **kwargs):
"""Return a diff between two branches/commits.

Args:
from_(str): Source branch/SHA
to(str): Destination branch/SHA
**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:
str: The diff
"""
path = f'/projects/{self.get_id()}/repository/merge_base?refs[]={from_}&refs[]={to}'
return self.manager.gitlab.http_get(path, **kwargs)

@cli.register_custom_action("Project")
@exc.on_http_error(exc.GitlabGetError)
def repository_contributors(self, **kwargs):
Expand Down