Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
14519fae
Commit
14519fae
authored
Aug 26, 2017
by
Greg Messner
Browse files
Added getCommits() methods for merge requests (#68).
parent
9f480b3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/MergeRequestApi.java
View file @
14519fae
...
@@ -7,7 +7,9 @@ import javax.ws.rs.core.GenericType;
...
@@ -7,7 +7,9 @@ import javax.ws.rs.core.GenericType;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.gitlab4j.api.models.MergeRequest
;
import
org.gitlab4j.api.utils.ISO8601
;
/**
/**
* This class implements the client side API for the GitLab merge request calls.
* This class implements the client side API for the GitLab merge request calls.
...
@@ -77,6 +79,54 @@ public class MergeRequestApi extends AbstractApi {
...
@@ -77,6 +79,54 @@ public class MergeRequestApi extends AbstractApi {
return
(
response
.
readEntity
(
MergeRequest
.
class
));
return
(
response
.
readEntity
(
MergeRequest
.
class
));
}
}
/**
* Get a list of merge request commits.
*
* GET /projects/:id/merge_requests/:merge_request_iid/commits
*
* @param projectId the project ID for the merge request
* @param mergeRequestId the ID of the merge request
* @return a list containing the commits for the specified merge request
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
List
<
Commit
>
getCommits
(
int
projectId
,
int
mergeRequestId
)
throws
GitLabApiException
{
return
(
getCommits
(
projectId
,
mergeRequestId
,
1
,
getDefaultPerPage
()));
}
/**
* Get a list of merge request commits.
*
* GET /projects/:id/merge_requests/:merge_request_iid/commits
*
* @param projectId the project ID for the merge request
* @param mergeRequestId the ID of the merge request
* @param page the page to get
* @param perPage the number of commits per page
* @return a list containing the commits for the specified merge request
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
List
<
Commit
>
getCommits
(
int
projectId
,
int
mergeRequestId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
().
withParam
(
"owned"
,
true
).
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"merge_request"
,
mergeRequestId
,
"commits"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Commit
>>()
{}));
}
/**
* Get a Pager of merge request commits.
*
* GET /projects/:id/merge_requests/:merge_request_iid/commits
*
* @param projectId the project ID for the merge request
* @param mergeRequestId the ID of the merge request
* @param itemsPerPage the number of Commit instances that will be fetched per page
* @return a Pager containing the commits for the specified merge request
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
Pager
<
Commit
>
getCommits
(
int
projectId
,
int
mergeRequestId
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Commit
>(
this
,
Commit
.
class
,
itemsPerPage
,
null
,
"projects"
,
projectId
,
"merge_request"
,
mergeRequestId
,
"commits"
));
}
/**
/**
* Creates a merge request and optionally assigns a reviewer to it.
* Creates a merge request and optionally assigns a reviewer to it.
*
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment