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
7ea980e5
Commit
7ea980e5
authored
Sep 17, 2017
by
Greg Messner
Browse files
Added getCommits(int projectId, String ref, Date since, Date until, String path).
parent
45dc78b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/CommitsApi.java
View file @
7ea980e5
...
...
@@ -87,6 +87,30 @@ public class CommitsApi extends AbstractApi {
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Commit
>>()
{}));
}
/**
* Get a list of repository commits in a project.
*
* GET /projects/:id/repository/commits
*
* @param projectId the project ID to get the list of commits for
* @param ref the name of a repository branch or tag or if not given the default branch
* @param since only commits after or on this date will be returned
* @param until only commits before or on this date will be returned
* @param path the path to file of a project
* @return a list containing the commits for the specified project ID
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
List
<
Commit
>
getCommits
(
int
projectId
,
String
ref
,
Date
since
,
Date
until
,
String
path
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
())
.
withParam
(
"ref_name"
,
ref
)
.
withParam
(
"since"
,
ISO8601
.
toString
(
since
,
false
))
.
withParam
(
"until"
,
ISO8601
.
toString
(
until
,
false
))
.
withParam
(
"path"
,
(
path
==
null
?
null
:
urlEncode
(
path
)));
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"commits"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Commit
>>()
{}));
}
/**
* Get a list of file commits in a project
*
...
...
@@ -100,10 +124,10 @@ public class CommitsApi extends AbstractApi {
*/
public
List
<
Commit
>
getCommits
(
int
projectId
,
String
ref
,
String
path
)
throws
GitLabApiException
{
Form
formData
=
new
GitLabApiForm
()
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
())
.
withParam
(
"ref_name"
,
ref
)
.
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
String
pathArg
=
(
path
==
null
||
path
.
isEmpty
())
?
"commits"
:
"commits"
+
"?path="
+
path
;
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
pathArg
);
.
withParam
(
"path"
,
(
path
==
null
?
null
:
urlEncode
(
path
)));
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"commits"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Commit
>>()
{}));
}
...
...
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