Skip to content

Commit

Permalink
Merge pull request gitlab4j#9 from lonfee88/master
Browse files Browse the repository at this point in the history
Fixed getTree and added getTree with file_path and ref parameters.
  • Loading branch information
gmessner committed May 21, 2015
2 parents 927ea6a + 62309b4 commit f44b8b4
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/main/java/com/messners/gitlab/api/RepositoryApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,33 @@ public List<Tag> getTags (Integer projectId) throws GitLabApiException {
* GET /projects/:id/repository/tree
*
* @param projectId
* @return a tree with the directories and files of a project
* @throws GitLabApiException
* @return a tree with the root directories and files of a project
* @throws GitLabApiException
*/
public List<TreeItem> getTree (Integer projectId) throws GitLabApiException {
Response response = put(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.
Expand Down

0 comments on commit f44b8b4

Please sign in to comment.