|
|
@@ -14,13 +14,10 @@ import com.nju.edu.gitlab.dto.project.VisibilityForm;
|
|
|
import com.nju.edu.gitlab.vo.*;
|
|
|
import com.nju.edu.gitlab.vo.commit.CommitVO;
|
|
|
import org.gitlab4j.api.GitLabApiException;
|
|
|
-import org.gitlab4j.api.models.User;
|
|
|
+import org.gitlab4j.api.models.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import okhttp3.*;
|
|
|
-import org.gitlab4j.api.models.AccessLevel;
|
|
|
-import org.gitlab4j.api.models.CommitAction;
|
|
|
-import org.gitlab4j.api.models.Visibility;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -824,4 +821,49 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi {
|
|
|
throw SeecoderGitlabException.IO_ERROR;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TreeItem> getRepositoryTree(int projectId, String filePath, String branch) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + String.format("/api/project/repositoryTree?projectId=%d&&filePath=%s&&branch=%s", projectId, filePath, branch));
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<List<TreeItem>>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsTreeItem error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MergeRequest mergeBranch(int projectId, String sourceBranch, String targetBranch, String title, String description, int reviewId) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + String.format("/api/project/mergeBranch?projectId=%d&&sourceBranch=%s&&targetBranch=%s&&title=%s&&description=%s&&reviewId=%d",
|
|
|
+ projectId, sourceBranch, targetBranch, title, description, reviewId));
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<MergeRequest>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsTreeItem error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|