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
e825044b
Commit
e825044b
authored
Mar 14, 2022
by
Aditya Bansal
Browse files
Comments and order_by support
parent
7062eea3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/Constants.java
View file @
e825044b
...
@@ -311,6 +311,29 @@ public interface Constants {
...
@@ -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(). */
/** Enum to use for specifying the scope when calling getPipelines(). */
public
enum
PipelineScope
{
public
enum
PipelineScope
{
...
...
src/main/java/org/gitlab4j/api/RepositoryApi.java
View file @
e825044b
...
@@ -671,18 +671,19 @@ public class RepositoryApi extends AbstractApi {
...
@@ -671,18 +671,19 @@ public class RepositoryApi extends AbstractApi {
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param page the page to get
* @param page the page to get
* @param perPage the number of projects per page
* @param perPage the number of projects per page
* @param sort optional param to sort the list of contributors by
* @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
* @return a List containing the contributors for the specified project ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Contributor
>
getContributors
(
Object
projectIdOrPath
,
int
page
,
int
perPage
,
String
sort
)
throws
GitLabApiException
{
public
List
<
Contributor
>
getContributors
(
Object
projectIdOrPath
,
int
page
,
int
perPage
,
ContributorOrderBy
orderBy
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
if
(
sort
!=
null
&&
!(
sort
.
equals
(
"asc"
)
||
sort
.
equals
(
"desc"
))
)
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
);
throw
new
RuntimeException
(
"Sort must be asc or desc"
);
if
(
sortOrder
!=
null
)
{
formData
.
withParam
(
"sort"
,
sortOrder
,
false
);
}
}
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
PAGE_PARAM
,
page
).
withParam
(
PER_PAGE_PARAM
,
perPage
);
if
(
orderBy
!=
null
)
{
if
(
sort
!=
null
)
{
formData
.
withParam
(
"order_by"
,
orderBy
,
false
);
formData
.
withParam
(
"sort"
,
sort
,
false
);
}
}
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
...
...
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