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
7062eea3
Commit
7062eea3
authored
Mar 14, 2022
by
Aditya Bansal
Browse files
Adding getContributors sort by asc / desc support
parent
09ed795b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/RepositoryApi.java
View file @
7062eea3
...
@@ -663,6 +663,33 @@ public class RepositoryApi extends AbstractApi {
...
@@ -663,6 +663,33 @@ public class RepositoryApi extends AbstractApi {
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Contributor
>>()
{
}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Contributor
>>()
{
}));
}
}
/**
* Get a list of contributors from a project and in the specified page range, sorted by specified param.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/contributors</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param page the page to get
* @param perPage the number of projects per page
* @param sort optional param to sort the list of contributors by
* @return a List containing the contributors for the specified project ID
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Contributor
>
getContributors
(
Object
projectIdOrPath
,
int
page
,
int
perPage
,
String
sort
)
throws
GitLabApiException
{
if
(
sort
!=
null
&&
!(
sort
.
equals
(
"asc"
)
||
sort
.
equals
(
"desc"
))
)
{
throw
new
RuntimeException
(
"Sort must be asc or desc"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
);
if
(
sort
!=
null
)
{
formData
.
withParam
(
"sort"
,
sort
,
false
);
}
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"contributors"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Contributor
>>()
{
}));
}
/**
/**
* Get a Pager of contributors from a project.
* Get a Pager of contributors from a project.
*
*
...
...
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