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
07407a57
Commit
07407a57
authored
Feb 10, 2017
by
Julien Lafourcade
Browse files
Add new method on RepositoryApi to get tree recursively
parent
42f5692a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/RepositoryApi.java
View file @
07407a57
...
...
@@ -158,10 +158,32 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException
*/
public
List
<
TreeItem
>
getTree
(
Integer
projectId
,
String
filePath
,
String
refName
)
throws
GitLabApiException
{
return
this
.
getTree
(
projectId
,
filePath
,
refName
,
false
);
}
/**
* Get a list of repository files and directories in a project.
*
* GET /projects/:id/repository/tree
*
* id (required) - The ID of a project
* path (optional) - The path inside repository. Used to get contend of subdirectories
* ref_name (optional) - The name of a repository branch or tag or if not given the default branch
* recursive (optional) - Boolean value used to get a recursive tree (false by default)
*
* @param projectId
* @param filePath
* @param refName
* @param recursive
* @return a tree with the directories and files of a project
* @throws GitLabApiException
*/
public
List
<
TreeItem
>
getTree
(
Integer
projectId
,
String
filePath
,
String
refName
,
Boolean
recursive
)
throws
GitLabApiException
{
Form
formData
=
new
Form
();
addFormParam
(
formData
,
"id"
,
projectId
,
true
);
addFormParam
(
formData
,
"path"
,
filePath
,
false
);
addFormParam
(
formData
,
"ref_name"
,
refName
,
false
);
addFormParam
(
formData
,
"recursive"
,
recursive
,
false
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"repository"
,
"tree"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
TreeItem
>>()
{
}));
...
...
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