Commit d3a1479b authored by Guillaume Smet's avatar Guillaume Smet

minor cosmetic cleanups

parent 2243612f
...@@ -711,56 +711,56 @@ public class GitlabAPI { ...@@ -711,56 +711,56 @@ public class GitlabAPI {
/** /**
* Get raw file content * Get raw file content
* *
* @param project Project * @param project The Project
* @param sha The commit or branch name * @param sha The commit or branch name
* @param filepath The path the file * @param filepath The path of the file
* @throws IOException * @throws IOException on gitlab api call error
*/ */
public byte[] getRawFileContent(GitlabProject project, String sha, String filepath) throws IOException { public byte[] getRawFileContent(GitlabProject project, String sha, String filepath) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/blobs/" + sha + "?filepath=" + filepath; Query query = new Query()
return retrieve().to(tailUrl, byte[].class); .append("filepath", filepath);
}
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/blobs/" + sha + query.toString();
return retrieve().to(tailUrl, byte[].class);
}
/** /**
* Get the raw file contents for a blob by blob SHA. * Get the raw file contents for a blob by blob SHA.
* *
* @param project Project * @param project The Project
* @param sha The commit or branch name * @param sha The commit or branch name
* @throws IOException * @throws IOException on gitlab api call error
*/ */
public byte[] getRawBlobContent(GitlabProject project, String sha) throws IOException { public byte[] getRawBlobContent(GitlabProject project, String sha) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/raw_blobs/" + sha; String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/raw_blobs/" + sha;
return retrieve().to(tailUrl, byte[].class); return retrieve().to(tailUrl, byte[].class);
} }
/** /**
* Get an archive of the repository * Get an archive of the repository
* *
* @param project Project * @param project The Project
* @throws IOException * @throws IOException on gitlab api call error
*/ */
public byte[] getFileArchive(GitlabProject project) throws IOException { public byte[] getFileArchive(GitlabProject project) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/archive"; String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/archive";
return retrieve().to(tailUrl, byte[].class); return retrieve().to(tailUrl, byte[].class);
} }
/** /**
* Get an archive of the repository * Get an archive of the repository
* *
* @param project Project * @param project The Project
* @param path The path inside repository. Used to get contend of subdirectories (optional) * @param path The path inside the repository. Used to get content of subdirectories (optional)
* @param ref_name The name of a repository branch or tag or if not given the default branch (optional) * @param ref_name The name of a repository branch or tag or if not given the default branch (optional)
* @throws IOException * @throws IOException on gitlab api call error
*/ */
public List<GitlabRepositoryTree> getRepositoryTree(GitlabProject project, String path, String ref_name) throws IOException { public List<GitlabRepositoryTree> getRepositoryTree(GitlabProject project, String path, String ref_name) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository" + GitlabRepositoryTree.URL; Query query = new Query()
if (path != null) { .appendIf("path", path)
tailUrl = tailUrl + (tailUrl.indexOf('?') > 0 ? '&' : '?') + "path=" + path; .appendIf("ref_name", ref_name);
}
if (ref_name != null) { String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository" + GitlabRepositoryTree.URL + query.toString();
tailUrl = tailUrl + (tailUrl.indexOf('?') > 0 ? '&' : '?') + "ref_name=" + ref_name;
}
GitlabRepositoryTree[] tree = retrieve().to(tailUrl, GitlabRepositoryTree[].class); GitlabRepositoryTree[] tree = retrieve().to(tailUrl, GitlabRepositoryTree[].class);
return Arrays.asList(tree); return Arrays.asList(tree);
} }
......
Markdown is supported
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