Skip to content

Allow project path in MergeRequestFilter #1274

@mhagnumdw

Description

@mhagnumdw

Currently, the MergeRequestFilter requires the project ID (number) to filter merge requests. It would be very useful to allow passing the project path (e.g., group/subgroup/project) directly in the filter, since retrieving the project ID often requires an extra API call.

try (GitLabApi gitLabApi = new GitLabApi(url, token)) {
    MergeRequestFilter filter = new MergeRequestFilter()
        .withSourceBranch(sourceBranch)
        .withTargetBranch(targetBranch)
        .withState(MergeRequestState.OPENED)
        .withProjectId(gitLabApi.getProjectApi().getProject(projectPath).getId()) // extra API call here
     // .withProjectIdOrPath(projectPath) // something like this
        ;
    List<MergeRequest> mergeRequests = gitLabApi.getMergeRequestApi().getMergeRequests(filter);
}

Alternatively, it would also help to provide an overloaded version of the method
public List<MergeRequest> getMergeRequests(Object projectIdOrPath) throws GitLabApiException
that accepts a MergeRequestFilter as a parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions