Skip to content

Commit

Permalink
Add catch block for InvalidUsernameException in CodeAnalysisJob
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico committed Jan 8, 2024
1 parent 5d795d7 commit dcba848
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/ch/usi/si/seart/job/CodeAnalysisJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import ch.usi.si.seart.exception.git.RepositoryDisabledException;
import ch.usi.si.seart.exception.git.RepositoryLockedException;
import ch.usi.si.seart.exception.git.RepositoryNotFoundException;
import ch.usi.si.seart.exception.git.config.InvalidUsernameException;
import ch.usi.si.seart.git.GitConnector;
import ch.usi.si.seart.git.LocalRepositoryClone;
import ch.usi.si.seart.github.GitHubRestConnector;
import ch.usi.si.seart.model.GitRepo;
import ch.usi.si.seart.model.Language;
import ch.usi.si.seart.model.join.GitRepoMetric;
Expand Down Expand Up @@ -54,6 +56,7 @@ public class CodeAnalysisJob implements Runnable {
AnalysisProperties analysisProperties;

GitConnector gitConnector;
GitHubRestConnector gitHubRestConnector;
CLOCConnector clocConnector;

ConversionService conversionService;
Expand Down Expand Up @@ -144,6 +147,22 @@ private void gatherCodeMetricsFor(@NotNull GitRepo gitRepo) {
} catch (RepositoryNotFoundException ignored) {
log.info("Deleting: {} [{}]", name, id);
gitRepoService.deleteRepoById(id);
} catch (InvalidUsernameException ex) {
switch (gitHubRestConnector.pingRepository(name)) {
case NOT_FOUND:
log.info("Deleting: {} [{}]", name, id);
gitRepoService.deleteRepoById(id);
return;
case FORBIDDEN, UNAVAILABLE_FOR_LEGAL_REASONS:
log.info("Disabling: {} [{}]", name, id);
gitRepo.setIsDisabled(true);
gitRepo.setLastAnalyzed();
gitRepoService.createOrUpdate(gitRepo);
return;
default:
log.error("Failed: {} [{}] ({})", name, id, ex.getClass().getSimpleName());
log.debug("", ex);
}
} catch (StaticCodeAnalysisException | GitException ex) {
log.error("Failed: {} [{}] ({})", name, id, ex.getClass().getSimpleName());
log.debug("", ex);
Expand Down

0 comments on commit dcba848

Please sign in to comment.