gitlab4j-api icon indicating copy to clipboard operation
gitlab4j-api copied to clipboard

Get information if Project is multibranch

Open dmytro-omelian opened this issue 3 years ago • 3 comments

As a user, I want to find out if Project is multibranch or not from GET /projects list

dmytro-omelian avatar Mar 17 '22 11:03 dmytro-omelian

Hello,

You can use something like this (not tested):

GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PERSONAL_ACCESS_TOKEN");

RepositoryApi repository = gitLabApi.getRepositoryApi();

// Adapt the list of projects your account has access to
gitLabApi.getProjectApi().getProjectsStream().each(project -> { // you can also use ProjectApi#getProjectsStream(ProjectFilter filter)
    boolean isProjectMultiBranches = repository.getBranches(project.getId(), int 2).size() > 1;

    // do whatever you want
});

jabby avatar Mar 18 '22 19:03 jabby

@jabby thanks a lot for your response. In this case, we make 2 requests using gitLabApi, maybe is there is an ability to find out about the multibranch project or not after we made only one request about the list of all projects?

The problem is that we only want to know if the project is multibranch or not (we don't want to know all branches and their information). But for this case, we should make n additional requests to get this information (n - number of projects)

Would be really grateful for any information)

dmytro-omelian avatar Mar 18 '22 20:03 dmytro-omelian

@Dichik gitlab4j-api is a wrapper of the official GitLab API. I don't find a way to do what you want in the official GitLab documentation. If you find any, point me the documentation page I will be happy to add corresponding implementation. See https://docs.gitlab.com/ee/api/api_resources.html for more informations about GitLab REST API capabilities.

BTW if there is no way, you can create a feature request in GitLab repository here https://gitlab.com/gitlab-org/gitlab/-/issues/

jabby avatar Mar 19 '22 01:03 jabby