Allow to get only 1 branch without using repository/branches
Description of the problem, including code/CLI snippet
Currently, to check if a branch already exists we need to use the method:
project.branches.get(self.branch_name)
Internally, it uses this:
class ProjectBranchManager(NoUpdateMixin, RESTManager):
_path = "/projects/{project_id}/repository/branches"
_obj_cls = ProjectBranch
_from_parent_attrs = {"project_id": "id"}
_create_attrs = RequiredOptional(required=("branch", "ref"))
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> ProjectBranch:
return cast(ProjectBranch, super().get(id=id, lazy=lazy, **kwargs))
Expected Behavior
It would be nice to check only for the branch we are looking for. GitLab API has an option for this.
API Endpoint: https://gitlab.com/api/v4/projects/{proyect_id}/repository/branches/{branch_to_search}
Actual Behavior
It retrieves all the branches using the endpoint https://gitlab.com/api/v4/projects/{proyect_id}/repository/branches
Specifications
- python-gitlab version: 4.4.0
- API version you are using (v3/v4): v4
- Gitlab server version (or gitlab.com): gitlab.com
Are you sure about this?
A get should not be retrieving all branches.
Can you give more info on why you say it is retrieving all branches?
This issue was marked stale because it has been open 60 days with no activity. Please remove the stale label or comment on this issue. Otherwise, it will be closed in 15 days.
This issue was closed because it has been marked stale for 15 days with no activity. If this issue is still valid, please re-open.