Skip to content

Commit 2483e64

Browse files
authored
get all merge requests for a group (#932)
Co-authored-by: Erkan <erkanerkisi>
1 parent ea9042e commit 2483e64

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/main/java/org/gitlab4j/api/MergeRequestApi.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,22 @@ public List<MergeRequest> getMergeRequests(MergeRequestFilter filter, int page,
8585
*
8686
* @param filter a MergeRequestFilter instance with the filter settings
8787
* @param itemsPerPage the number of MergeRequest instances that will be fetched per page
88-
* @return all merge requests for the specified project matching the filter
88+
* @return all merge requests for the specified project/group matching the filter
8989
* @throws GitLabApiException if any exception occurs
9090
*/
9191
public Pager<MergeRequest> getMergeRequests(MergeRequestFilter filter, int itemsPerPage) throws GitLabApiException {
9292

9393
MultivaluedMap<String, String> queryParams = (filter != null ? filter.getQueryParams().asMap() : null);
94-
if (filter != null && (filter.getProjectId() != null && filter.getProjectId().intValue() > 0) ||
95-
(filter.getIids() != null && filter.getIids().size() > 0)) {
94+
if (filter != null && ((filter.getProjectId() != null && filter.getProjectId().intValue() > 0) ||
95+
(filter.getIids() != null && filter.getIids().size() > 0))) {
9696

9797
if (filter.getProjectId() == null || filter.getProjectId().intValue() == 0) {
9898
throw new RuntimeException("project ID cannot be null or 0");
9999
}
100100

101101
return (new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, queryParams, "projects", filter.getProjectId(), "merge_requests"));
102+
} else if (filter != null && filter.getGroupId() != null && filter.getGroupId().intValue() > 0) {
103+
return (new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, queryParams, "groups", filter.getGroupId(), "merge_requests"));
102104
} else {
103105
return (new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, queryParams, "merge_requests"));
104106
}

src/main/java/org/gitlab4j/api/models/MergeRequestFilter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
public class MergeRequestFilter {
2323

2424
private Long projectId;
25+
private Long groupId;
2526
private List<Long> iids;
2627
private MergeRequestState state;
2728
private MergeRequestOrderBy orderBy;
@@ -315,6 +316,19 @@ public void setWip(Boolean wip) {
315316
this.wip = wip;
316317
}
317318

319+
public Long getGroupId() {
320+
return groupId;
321+
}
322+
323+
public void setGroupId(Long groupId) {
324+
this.groupId = groupId;
325+
}
326+
327+
public MergeRequestFilter withGroupId(Long groupId) {
328+
this.groupId = groupId;
329+
return (this);
330+
}
331+
318332
public MergeRequestFilter withWip(Boolean wip) {
319333
this.wip = wip;
320334
return (this);

0 commit comments

Comments
 (0)