- Notifications
You must be signed in to change notification settings - Fork673
feat: add support for merge_base API#2236
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -10,7 +10,7 @@ | ||||||||||||
import gitlab | ||||||||||||
from gitlab import cli | ||||||||||||
from gitlab import exceptions as exc | ||||||||||||
from gitlab importtypes,utils | ||||||||||||
if TYPE_CHECKING: | ||||||||||||
# When running mypy we use these as the base classes | ||||||||||||
@@ -246,6 +246,32 @@ def repository_archive( | ||||||||||||
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]: | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This made me think if we should start forcing these to just be a MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thanks@JohnVillalovos! Makes sense to me! I was looking at doing this via overloading But it requires quite a few overloads for all the possible signatures. This is what I was looking athttps://medium.com/analytics-vidhya/making-sense-of-typing-overload-437e6deecade. | ||||||||||||
"""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) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. To force it to be a Suggested change
| ||||||||||||
@cli.register_custom_action("Project") | ||||||||||||
@exc.on_http_error(exc.GitlabDeleteError) | ||||||||||||
def delete_merged_branches(self, **kwargs: Any) -> None: | ||||||||||||