Search in sources :

Example 6 with GitRepositoryClient

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();
    }
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Example 7 with GitRepositoryClient

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;
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Example 8 with GitRepositoryClient

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();
    }
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Example 9 with GitRepositoryClient

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();
    }
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Example 10 with GitRepositoryClient

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);
    });
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Aggregations

GitRepositoryClient (net.nemerosa.ontrack.git.GitRepositoryClient)13 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 GitBranchConfigurationProperty (net.nemerosa.ontrack.extension.git.property.GitBranchConfigurationProperty)1 ConfiguredIssueService (net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)1 SCMBuildView (net.nemerosa.ontrack.extension.scm.model.SCMBuildView)1 SCMIssueCommitBranchInfo (net.nemerosa.ontrack.extension.scm.model.SCMIssueCommitBranchInfo)1