cloneStatus field added

This commit is contained in:
sumedh
2024-10-21 12:27:02 +05:30
parent 61753bb01a
commit e2a5f24dcb
4 changed files with 16 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ public class KSGitInfo {
private String repoPath;
private KSGitIngestionInfo ksGitIngestionInfo;
private HashMap<String, String> gitModifiedFiles;
private String cloneStatus;
private String ingestionStatus;
private Date ingestionDate;
private String ingestionDateFormat;

View File

@@ -73,7 +73,7 @@ public class GitRepositoryIngestor {
Optional<KSGitInfo> optionalDocument = ksGitInfoRepository.findByRepoNameAndBranchName(repo,branchName);
if (optionalDocument.isPresent()) {
KSGitInfo ksGitInfo = optionalDocument.get();
if ("REPO-CLONE-COMPLETED".equals(ksGitInfo.getIngestionStatus())) {
if ("COMPLETED".equals(ksGitInfo.getCloneStatus())) {
ResultDTO repoResult = ingestRepo(repo,branchName, ksGitInfo);
// Notify clients via WebSocket or other mechanisms
//notifyClients(repo, branchName, repoResult);
@@ -106,7 +106,7 @@ public class GitRepositoryIngestor {
logger.info("Repository path of Ingestion : {}", repoPath);
try (Git git = Git.open(new File(repoPath))) {
ksGitInfo.setIngestionStatus("INGESTION-IN-PROGRESS");
ksGitInfo.setIngestionStatus("IN-PROGRESS");
ksGitInfoRepository.save(ksGitInfo);
KSGitIngestionInfo ingestionInfo = ksGitInfo.getKsGitIngestionInfo();
@@ -154,7 +154,7 @@ public class GitRepositoryIngestor {
logger.info("Documents embedded Successfully");
} catch (IOException e) {
ksGitInfo.setIngestionStatus("INGESTION-ERROR");
ksGitInfo.setIngestionStatus("ERROR");
ksGitInfo.setIngestionDate(new Date());
ksGitInfoRepository.save(ksGitInfo);
@@ -172,7 +172,7 @@ public class GitRepositoryIngestor {
resultDTO.setMessage("Ingestion completed successfully");
} catch (IOException e) {
ksGitInfo.setIngestionStatus("INGESTION-ERROR");
ksGitInfo.setIngestionStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
logger.error("Error opening repository", e);
@@ -180,14 +180,14 @@ public class GitRepositoryIngestor {
resultDTO.setMessage("Error opening repository: " + e.getMessage());
}
}catch (BranchCheckoutException e){
ksGitInfo.setIngestionStatus("INGESTION-ERROR");
ksGitInfo.setIngestionStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
logger.error("Error checking out repository branch", e);
resultDTO.setSuccess(false);
resultDTO.setMessage("Error checking out repository branch: " + e.getMessage());
} catch (Exception e) {
ksGitInfo.setIngestionStatus("INGESTION-ERROR");
ksGitInfo.setIngestionStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
logger.error("Error during ingestion", e);
@@ -258,7 +258,7 @@ public class GitRepositoryIngestor {
logger.info("Repository path : " + repoPath);
try (Git git = Git.open(new File(repoPath))) {
ksGitInfo.setIngestionStatus("IN PROGRESS");
ksGitInfo.setIngestionStatus("IN-PROGRESS");
KSGitIngestionInfo ingestionInfo = ksGitInfo.getKsGitIngestionInfo();
logger.info("Metadata : " + ingestionInfo.getMetadata());
ksGitInfoRepository.save(ksGitInfo);

View File

@@ -114,7 +114,7 @@ public class GitService {
@Async
public CompletableFuture<Void> cloneRepository(String Source, String repoName, String branchName, String group, String tokenType,KSGitInfo ksGitInfo) {
return CompletableFuture.runAsync(() -> {
ksGitInfo.setIngestionStatus("REPO-CLONE-IN-PROGRESS");
ksGitInfo.setCloneStatus("IN-PROGRESS");
ksGitInfoRepository.save(ksGitInfo);
ResultDTO resultDTO = new ResultDTO();
@@ -152,7 +152,7 @@ public class GitService {
String checkoutMessage = checkOutRepository(repoName, branchName);
ksGitInfo.setIngestionStatus("REPO-CLONE-COMPLETED");
ksGitInfo.setCloneStatus("COMPLETED");
ksGitInfoRepository.save(ksGitInfo);
resultDTO.setSuccess(true);
@@ -162,7 +162,7 @@ public class GitService {
String errorMessage = "Git API error: " + e.getMessage();
logger.error(errorMessage, e);
ksGitInfo.setIngestionStatus("REPO-CLONE-FAILED");
ksGitInfo.setCloneStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
resultDTO.setSuccess(false);
@@ -172,7 +172,7 @@ public class GitService {
String errorMessage = "Branch Checkout Error: "+ e.getMessage();
logger.error(errorMessage,e);
ksGitInfo.setIngestionStatus("REPO-CLONE-FAILED");
ksGitInfo.setCloneStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
resultDTO.setSuccess(false);
@@ -182,7 +182,7 @@ public class GitService {
String errorMessage = "Git Clone Error: "+ e.getMessage();
logger.error(errorMessage,e);
ksGitInfo.setIngestionStatus("REPO-CLONE-FAILED");
ksGitInfo.setCloneStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
resultDTO.setSuccess(false);
@@ -192,7 +192,7 @@ public class GitService {
String errorMessage = "UnExpected Error: "+ e.getMessage();
logger.error(errorMessage,e);
ksGitInfo.setIngestionStatus("REPO-CLONE-FAILED");
ksGitInfo.setCloneStatus("ERROR");
ksGitInfoRepository.save(ksGitInfo);
resultDTO.setSuccess(false);

View File

@@ -28,7 +28,8 @@ public class GitUtils {
info.setBranch(gitCloneInput.getBranch());
info.setCommitId(gitCloneInput.getCommitId());
info.setRepoPath(basePath+ File.separator +gitCloneInput.getRepoName());
info.setIngestionStatus("REPO-NEW");
info.setCloneStatus("NEW");
info.setIngestionStatus("NEW");
info.setIngestionDate(new Date());
info.setIngestionDateFormat(new SimpleDateFormat("MM/dd/yy").format(new Date()));