|
@@ -9,9 +9,8 @@ import cn.seecoder.web.service.commit.CommitQualityService;
|
|
|
import cn.seecoder.web.service.commit.CommitService;
|
|
import cn.seecoder.web.service.commit.CommitService;
|
|
|
import com.nju.edu.gitlab.SeecoderGitlabApi;
|
|
import com.nju.edu.gitlab.SeecoderGitlabApi;
|
|
|
import com.nju.edu.gitlab.vo.DiffVO;
|
|
import com.nju.edu.gitlab.vo.DiffVO;
|
|
|
-import org.slf4j.Logger;
|
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -26,31 +25,23 @@ import java.util.Set;
|
|
|
* @description:
|
|
* @description:
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
public class CommitServiceImpl implements CommitService {
|
|
public class CommitServiceImpl implements CommitService {
|
|
|
|
|
|
|
|
- private static final Logger log = LoggerFactory.getLogger(CommitServiceImpl.class);
|
|
|
|
|
-
|
|
|
|
|
private final SeecoderGitlabApi seecoderGitlabApi;
|
|
private final SeecoderGitlabApi seecoderGitlabApi;
|
|
|
|
|
|
|
|
private final CommitLinkService commitLinkService;
|
|
private final CommitLinkService commitLinkService;
|
|
|
|
|
|
|
|
private final CommitQualityService commitQualityService;
|
|
private final CommitQualityService commitQualityService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- public CommitServiceImpl(SeecoderGitlabApi seecoderGitlabApi, CommitLinkService commitLinkService,
|
|
|
|
|
- CommitQualityService commitQualityService) {
|
|
|
|
|
- this.seecoderGitlabApi = seecoderGitlabApi;
|
|
|
|
|
- this.commitLinkService = commitLinkService;
|
|
|
|
|
- this.commitQualityService = commitQualityService;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<CommitVO> getCommitsByBranchName(Integer projectId, String BranchName) {
|
|
|
|
|
- List<CommitVO> allCommits = new ArrayList<CommitVO>();
|
|
|
|
|
|
|
+ public List<CommitVO> getCommitsByBranchName(Integer projectId, String branchName) {
|
|
|
|
|
+ List<CommitVO> allCommits = new ArrayList<>();
|
|
|
Map<String, CommitCheckResultEnum> commitsQualityMapByProjectId = commitQualityService.getCommitsQualityMapByProjectId(projectId);
|
|
Map<String, CommitCheckResultEnum> commitsQualityMapByProjectId = commitQualityService.getCommitsQualityMapByProjectId(projectId);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- List<com.nju.edu.gitlab.vo.commit.CommitVO> commitsResponse = seecoderGitlabApi.getCommitsByBranch(projectId, BranchName);
|
|
|
|
|
|
|
+ List<com.nju.edu.gitlab.vo.commit.CommitVO> commitsResponse = seecoderGitlabApi.getCommitsByBranch(projectId, branchName);
|
|
|
for (com.nju.edu.gitlab.vo.commit.CommitVO commit : commitsResponse) {
|
|
for (com.nju.edu.gitlab.vo.commit.CommitVO commit : commitsResponse) {
|
|
|
CommitVO commitVO = new CommitVO(commit);
|
|
CommitVO commitVO = new CommitVO(commit);
|
|
|
String hash = commitVO.getId();
|
|
String hash = commitVO.getId();
|
|
@@ -70,7 +61,7 @@ public class CommitServiceImpl implements CommitService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("Failed to query commits by branch, projectId={}, branchName={}", projectId, BranchName, e);
|
|
|
|
|
|
|
+ log.error("Failed to query commits by branch, projectId={}, branchName={}", projectId, branchName, e);
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
|
|
|