|
|
@@ -650,6 +650,53 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<CommitVO> getCommitsByBranch(int projectId, String branchName) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + "/api/project/" + projectId + "/branch-commit/" + branchName)
|
|
|
+ .get();
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ List<CommitVO> commitVOList = new ArrayList<>();
|
|
|
+ commitVOList = processResponse(objectMapper, response, new TypeReference<List<CommitVO>>() {
|
|
|
+ });
|
|
|
+ return commitVOList;
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsString error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommitVO getCommitByHash(int projectId, String hash) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + "/api/project/" + projectId + "/branch-commit/" + hash)
|
|
|
+ .get();
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<CommitVO>() {});
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsString error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<BranchVO> getProjectBranches(int projectId) throws SeecoderGitlabException {
|
|
|
try {
|