use of fr.inria.jtravis.entities.Repository in project repairnator by Spirals-Team.
the class RTScanner method isRepositoryInteresting.
public boolean isRepositoryInteresting(int repositoryId) {
if (this.blackListedRepository.contains(repositoryId)) {
// LOGGER.debug("Repo already blacklisted (id: "+repositoryId+")");
return false;
}
if (this.whiteListedRepository.contains(repositoryId)) {
// LOGGER.debug("Repo already whitelisted (id: "+repositoryId+")");
return true;
}
if (this.tempBlackList.containsKey(repositoryId)) {
if (this.tempBlackList.get(repositoryId).after(new Date())) {
return false;
} else {
this.tempBlackList.remove(repositoryId);
}
}
Repository repository = RepositoryHelper.getRepositoryFromId(repositoryId);
if (repository != null) {
Build masterBuild = BuildHelper.getLastSuccessfulBuildFromMaster(repository, false, 5);
if (masterBuild == null) {
this.addInTempBlackList(repository, "No successful build found.");
return false;
} else {
if (masterBuild.getConfig().getLanguage() == null || !masterBuild.getConfig().getLanguage().equals("java")) {
this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getConfig().getLanguage());
return false;
}
if (masterBuild.getBuildTool() == BuildTool.GRADLE) {
this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, "");
return false;
} else if (masterBuild.getBuildTool() == BuildTool.UNKNOWN) {
this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, "");
return false;
}
if (!masterBuild.getJobs().isEmpty()) {
Job firstJob = masterBuild.getJobs().get(0);
Log jobLog = firstJob.getLog();
if (jobLog.getTestsInformation() != null && jobLog.getTestsInformation().getRunning() > 0) {
LOGGER.info("Tests has been found in repository " + repository.getSlug() + " (id: " + repositoryId + ") build (id: " + masterBuild.getId() + "). The repo is now whitelisted.");
this.addInWhitelistRepository(repository);
return true;
} else {
this.addInTempBlackList(repository, "No test found");
}
} else {
LOGGER.info("No job found in repository " + repository.getSlug() + " (id: " + repositoryId + ") build (id: " + masterBuild.getId() + "). It is not considered right now.");
}
}
} else {
LOGGER.info("Repository not found with the following id: " + repositoryId + " it will be temporary blacklisted");
Date expirationDate = new Date(new Date().toInstant().plusSeconds(DURATION_IN_TEMP_BLACKLIST).toEpochMilli());
this.tempBlackList.put(repositoryId, expirationDate);
}
return false;
}
use of fr.inria.jtravis.entities.Repository in project repairnator by Spirals-Team.
the class PatchNotifier method observe.
public void observe(ProjectInspector inspector) {
JobStatus status = inspector.getJobStatus();
Build buggyBuild = inspector.getBuggyBuild();
Repository repository = buggyBuild.getRepository();
if (status.isHasBeenPatched()) {
String subject = "Patched build: " + buggyBuild.getId() + " - " + repository.getSlug();
String text = "Hurray !\n\n" + "Patch(es) has been found for the following build: " + Utils.getTravisUrl(buggyBuild.getId(), repository.getSlug()) + ".\n";
if (status.isHasBeenPushed()) {
String slug = repository.getSlug();
String repoURL = Utils.getGithubRepoUrl(slug);
String branchName = buggyBuild.getCommit().getBranch();
String[] divideSlug = slug.split("/");
String projectName = divideSlug[1];
text += "Data about patches has been pushed on the following branch: " + status.getGitBranchUrl() + ".\n\n";
text += "Follow those instruction to create a pull request:\n";
text += "mkdir " + projectName + "\n";
text += "cd " + projectName + "\n";
text += "git init\n";
text += "git fetch " + repoURL + " " + branchName + "\n";
text += "git checkout -b patch FETCH_HEAD\n";
text += "vi [file_to_patch]\n";
text += "git commit -m \"tentative patch\" -a\n";
if (status.isHasBeenForked()) {
text += "git push " + status.getForkURL() + "\n";
} else {
text += "Then fork the repository (" + slug + ") from Github interface\n";
text += "git push [url to the fork]\n";
}
}
text += "You may find several information on the following about those patches: \n";
if (status.getNopolInformations() != null && !status.getNopolPatches().isEmpty() && !this.alreadyNotifiedForNopol) {
text += this.notifyForNopol(status);
this.notifyEngines("[NOPOL] " + subject, text);
}
if (status.getNpeFixPatches() != null && !status.getNpeFixPatches().isEmpty() && !this.alreadyNotifiedForNPEFix) {
text += this.notifyForNPEFix(status);
this.notifyEngines("[NPEFIX] " + subject, text);
}
if (status.getAstorPatches() != null && !status.getAstorPatches().isEmpty() && !this.alreadyNotifiedForAstor) {
text += this.notifityForAstor(status);
this.notifyEngines("[ASTOR] " + subject, text);
}
}
}