in log4j-catalog/log4j-catalog-git/src/main/java/org/apache/logging/log4j/catalog/git/dao/GitCatalogDao.java [188:231]
private void updateRepo() {
File localRepoFile = new File(localRepoPath);
if (!localRepoFile.exists()) {
LOGGER.debug("local git repo {} does not exist - creating it", localRepoPath);
localRepoFile.getParentFile().mkdirs();
CloneCommand cloneCommand = Git.cloneRepository().setURI(remoteRepoUri).setDirectory(localRepoFile);
if (branch != null) {
cloneCommand.setBranch(branch);
}
if (credentialsProvider != null) {
cloneCommand.setCredentialsProvider(credentialsProvider);
}
if (transportConfigCallback != null) {
cloneCommand.setTransportConfigCallback(transportConfigCallback);
}
try (Git git = cloneCommand.call()) {
catalogFile = new File(localRepoFile, catalogPath);
} catch (Exception ex) {
throw new CatalogNotFoundException("Unable to clone remote catalog at " + remoteRepoUri + " to " + localRepoPath, ex);
}
} else {
try {
LOGGER.debug("local git repo {} exists - updating", localRepoPath);
localRepo = new FileRepository(localRepoPath + "/.git");
catalogFile = new File(localRepoFile, catalogPath);
git = new Git(localRepo);
PullCommand pullCommand = git.pull();
try {
if (credentialsProvider != null) {
pullCommand.setCredentialsProvider(credentialsProvider);
}
if (transportConfigCallback != null) {
pullCommand.setTransportConfigCallback(transportConfigCallback);
}
pullCommand.call();
} catch (GitAPIException gitApiException) {
LOGGER.error("Exception", gitApiException);
}
} catch (Exception exception) {
throw new CatalogReadException("Unable to pull remote catalog at " + remoteRepoUri + " to " + localRepoPath, exception);
}
}
}