Skip to content

Commit

Permalink
feat(qodana): ✨ Dont remine old repositories again if hash is already…
Browse files Browse the repository at this point in the history
… analyzed
  • Loading branch information
MartinWitt committed Jun 24, 2023
1 parent e9b497f commit 0f602e9
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ private void mineRandomRepo() {
mineRandomRepo();
return;
}

if (checkoutResult instanceof ProjectResult.Success success) {
String commitHash = success.project().commitHash();
if (isAlreadyMined(success, commitHash)) {
logger.atInfo().log(
"Project %s already analyzed with commit hash %s", success.project(), commitHash);
tryDeleteProject(success);
mineRandomRepo();
}
logger.atInfo().log("Successfully checked out project %s", success.project());
var qodanaResult = analyzeProject(success);
if (qodanaResult instanceof QodanaResult.Failure failure) {
Expand All @@ -111,6 +119,11 @@ private void mineRandomRepo() {
}
}

private boolean isAlreadyMined(ProjectResult.Success success, String commitHash) {
return projectRepository.findByProjectUrl(success.project().url()).stream()
.anyMatch(it -> !it.getCommitHashes().contains(commitHash));
}

private ProjectResult checkoutProject(Project project) throws IOException {
return projectService.handleProjectRequest(new ProjectRequest.WithUrl(project.getProjectUrl()));
}
Expand Down

0 comments on commit 0f602e9

Please sign in to comment.