Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
73817d15
Unverified
Commit
73817d15
authored
3 years ago
by
Gautier de Saint Martin Lacaze
Committed by
GitHub
3 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #822 from maddymanu/add-contributos-sort
Adding getContributors sort by asc / desc support
parents
cf58df40
e825044b
main
5.0.x
5.0.x.jdk17
6.x
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/gitlab4j/api/Constants.java
+23
-0
src/main/java/org/gitlab4j/api/Constants.java
src/main/java/org/gitlab4j/api/RepositoryApi.java
+28
-0
src/main/java/org/gitlab4j/api/RepositoryApi.java
with
51 additions
and
0 deletions
+51
-0
src/main/java/org/gitlab4j/api/Constants.java
+
23
-
0
View file @
73817d15
...
...
@@ -311,6 +311,29 @@ public interface Constants {
}
}
/** Enum to use for ordering the results of getContibutors(). */
public
enum
ContributorOrderBy
{
NAME
,
EMAIL
,
COMMITS
;
private
static
JacksonJsonEnumHelper
<
ContributorOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
ContributorOrderBy
.
class
);
@JsonCreator
public
static
ContributorOrderBy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
/** Enum to use for specifying the scope when calling getPipelines(). */
public
enum
PipelineScope
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/RepositoryApi.java
+
28
-
0
View file @
73817d15
...
...
@@ -663,6 +663,34 @@ public class RepositoryApi extends AbstractApi {
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 orderBy (optional param) returns contributors ordered by NAME, EMAIL, or COMMITS. Default is COMMITS
* @param sortOrder (optional param) returns contributors sorted in ASC or DESC order. Default is ASC
* @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
,
ContributorOrderBy
orderBy
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
);
if
(
sortOrder
!=
null
)
{
formData
.
withParam
(
"sort"
,
sortOrder
,
false
);
}
if
(
orderBy
!=
null
)
{
formData
.
withParam
(
"order_by"
,
orderBy
,
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.
*
...
...
This diff is collapsed.
Click to expand 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
Menu
Explore
Projects
Groups
Snippets