|
7 | 7 | import javax.ws.rs.core.Response;
|
8 | 8 |
|
9 | 9 | import org.gitlab4j.api.GitLabApi.ApiVersion;
|
| 10 | +import org.gitlab4j.api.models.Commit; |
10 | 11 | import org.gitlab4j.api.models.MergeRequest;
|
| 12 | +import org.gitlab4j.api.utils.ISO8601; |
11 | 13 |
|
12 | 14 | /**
|
13 | 15 | * This class implements the client side API for the GitLab merge request calls.
|
@@ -77,6 +79,54 @@ public MergeRequest getMergeRequest(Integer projectId, Integer mergeRequestId) t
|
77 | 79 | return (response.readEntity(MergeRequest.class));
|
78 | 80 | }
|
79 | 81 |
|
| 82 | + /** |
| 83 | + * Get a list of merge request commits. |
| 84 | + * |
| 85 | + * GET /projects/:id/merge_requests/:merge_request_iid/commits |
| 86 | + * |
| 87 | + * @param projectId the project ID for the merge request |
| 88 | + * @param mergeRequestId the ID of the merge request |
| 89 | + * @return a list containing the commits for the specified merge request |
| 90 | + * @throws GitLabApiException GitLabApiException if any exception occurs during execution |
| 91 | + */ |
| 92 | + public List<Commit> getCommits(int projectId, int mergeRequestId) throws GitLabApiException { |
| 93 | + return (getCommits(projectId, mergeRequestId, 1, getDefaultPerPage())); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Get a list of merge request commits. |
| 98 | + * |
| 99 | + * GET /projects/:id/merge_requests/:merge_request_iid/commits |
| 100 | + * |
| 101 | + * @param projectId the project ID for the merge request |
| 102 | + * @param mergeRequestId the ID of the merge request |
| 103 | + * @param page the page to get |
| 104 | + * @param perPage the number of commits per page |
| 105 | + * @return a list containing the commits for the specified merge request |
| 106 | + * @throws GitLabApiException GitLabApiException if any exception occurs during execution |
| 107 | + */ |
| 108 | + public List<Commit> getCommits(int projectId, int mergeRequestId, int page, int perPage) throws GitLabApiException { |
| 109 | + Form formData = new GitLabApiForm().withParam("owned", true).withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage); |
| 110 | + Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "merge_request", mergeRequestId, "commits"); |
| 111 | + return (response.readEntity(new GenericType<List<Commit>>() {})); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Get a Pager of merge request commits. |
| 116 | + * |
| 117 | + * GET /projects/:id/merge_requests/:merge_request_iid/commits |
| 118 | + * |
| 119 | + * @param projectId the project ID for the merge request |
| 120 | + * @param mergeRequestId the ID of the merge request |
| 121 | + * @param itemsPerPage the number of Commit instances that will be fetched per page |
| 122 | + * @return a Pager containing the commits for the specified merge request |
| 123 | + * @throws GitLabApiException GitLabApiException if any exception occurs during execution |
| 124 | + */ |
| 125 | + public Pager<Commit> getCommits(int projectId, int mergeRequestId, int itemsPerPage) throws GitLabApiException { |
| 126 | + return (new Pager<Commit>(this, Commit.class, itemsPerPage, null, |
| 127 | + "projects", projectId, "merge_request", mergeRequestId, "commits")); |
| 128 | + } |
| 129 | + |
80 | 130 | /**
|
81 | 131 | * Creates a merge request and optionally assigns a reviewer to it.
|
82 | 132 | *
|
|
0 commit comments