use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.
the class GitHealthIndicator method getHealth.
@Override
protected Health getHealth(BasicGitConfiguration config) {
try {
GitRepositoryClient client = repositoryClientFactory.getClient(config.getGitRepository());
client.getRemoteBranches();
return Health.up().build();
} catch (Exception ex) {
return Health.down(ex).build();
}
}
use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.
the class GitRepositoryClientFactoryImpl method createAndRegisterRepositoryClient.
protected GitRepositoryClient createAndRegisterRepositoryClient(GitRepository repository) {
GitRepositoryClient client = createRepositoryClient(repository);
repositoryClientCache.put(repository.getRemote(), client);
return client;
}
use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.
the class GitRepositoryClientFactoryImpl method getClient.
@Override
public GitRepositoryClient getClient(GitRepository repository) {
String remote = repository.getRemote();
lock.lock();
try {
// Gets any existing repository in the cache
GitRepositoryClient repositoryClient = repositoryClientCache.getIfPresent(remote);
if (repositoryClient != null && repositoryClient.isCompatible(repository)) {
return repositoryClient;
} else // Repository to be created
{
return createAndRegisterRepositoryClient(repository);
}
} finally {
lock.unlock();
}
}
use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.
the class GitServiceImpl method lookupCommit.
@Override
public Optional<GitUICommit> lookupCommit(GitConfiguration configuration, String id) {
// Gets the client client for this configuration
GitRepositoryClient gitClient = gitRepositoryClientFactory.getClient(configuration.getGitRepository());
// Gets the commit
Optional<GitCommit> optGitCommit = gitClient.getCommitFor(id);
if (optGitCommit.isPresent()) {
String commitLink = configuration.getCommitLink();
List<? extends MessageAnnotator> messageAnnotators = getMessageAnnotators(configuration);
return Optional.of(toUICommit(commitLink, messageAnnotators, optGitCommit.get()));
} else {
return Optional.empty();
}
}
use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.
the class GitServiceImpl method download.
@Override
public Optional<String> download(Branch branch, String path) {
securityService.checkProjectFunction(branch, ProjectConfig.class);
return transactionService.doInTransaction(() -> {
GitBranchConfiguration branchConfiguration = getRequiredBranchConfiguration(branch);
GitRepositoryClient client = gitRepositoryClientFactory.getClient(branchConfiguration.getConfiguration().getGitRepository());
return client.download(branchConfiguration.getBranch(), path);
});
}
Aggregations