|
10 | 10 | import gitlab |
11 | 11 | from gitlab import cli |
12 | 12 | from gitlab import exceptions as exc |
13 | | -from gitlab import utils |
| 13 | +from gitlab import types, utils |
14 | 14 |
|
15 | 15 | if TYPE_CHECKING: |
16 | 16 | # When running mypy we use these as the base classes |
@@ -246,6 +246,32 @@ def repository_archive( |
246 | 246 | result, streamed, action, chunk_size, iterator=iterator |
247 | 247 | ) |
248 | 248 |
|
| 249 | + @cli.register_custom_action("Project", ("refs",)) |
| 250 | + @exc.on_http_error(exc.GitlabGetError) |
| 251 | + def repository_merge_base( |
| 252 | + self, refs: List[str], **kwargs: Any |
| 253 | + ) -> Union[Dict[str, Any], requests.Response]: |
| 254 | + """Return a diff between two branches/commits. |
| 255 | +
|
| 256 | + Args: |
| 257 | + refs: The refs to find the common ancestor of. Multiple refs can be passed. |
| 258 | + **kwargs: Extra options to send to the server (e.g. sudo) |
| 259 | +
|
| 260 | + Raises: |
| 261 | + GitlabAuthenticationError: If authentication is not correct |
| 262 | + GitlabGetError: If the server failed to perform the request |
| 263 | +
|
| 264 | + Returns: |
| 265 | + The common ancestor commit (*not* a RESTObject) |
| 266 | + """ |
| 267 | + path = f"/projects/{self.encoded_id}/repository/merge_base" |
| 268 | + query_data, _ = utils._transform_types( |
| 269 | + data={"refs": refs}, |
| 270 | + custom_types={"refs": types.ArrayAttribute}, |
| 271 | + transform_data=True, |
| 272 | + ) |
| 273 | + return self.manager.gitlab.http_get(path, query_data=query_data, **kwargs) |
| 274 | + |
249 | 275 | @cli.register_custom_action("Project") |
250 | 276 | @exc.on_http_error(exc.GitlabDeleteError) |
251 | 277 | def delete_merged_branches(self, **kwargs: Any) -> None: |
|
0 commit comments