Commit 62309b4a authored by 六幻's avatar 六幻
Browse files

add a getTree method with 2 more additional parameters

parent f3593803
......@@ -128,14 +128,33 @@ public class RepositoryApi extends AbstractApi {
* GET /projects/:id/repository/tree
*
* @param projectId
* @return a tree with the directories and files of a project
* @return a tree with the root directories and files of a project
* @throws GitLabApiException
*/
public List<TreeItem> getTree (Integer projectId) throws GitLabApiException {
Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "tree");
return (response.readEntity(new GenericType<List<TreeItem>>() {}));
return this.getTree(projectId, "/", "master");
}
/**
* 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
* @return a tree with the directories and files of a project
* @throws GitLabApiException
*/
public List<TreeItem> getTree (Integer projectId, String filePath, String refName) throws GitLabApiException {
Form formData = new Form();
addFormParam(formData, "id", projectId, true);
addFormParam(formData, "path", filePath, false);
addFormParam(formData, "ref_name", refName, false);
Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "tree");
return (response.readEntity(new GenericType<List<TreeItem>>() {}));
}
/**
* Get the raw file contents for a file by commit sha and path.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment