Search in sources :

Example 11 with GitRepositoryClient

use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.

the class GitServiceImpl method getGitSynchronisationInfo.

private GitSynchronisationInfo getGitSynchronisationInfo(GitConfiguration gitConfiguration) {
    // Gets the client for this configuration
    GitRepositoryClient client = gitRepositoryClientFactory.getClient(gitConfiguration.getGitRepository());
    // Gets the status
    GitSynchronisationStatus status = client.getSynchronisationStatus();
    // Collects the branch info
    List<GitBranchInfo> branches;
    if (status == GitSynchronisationStatus.IDLE) {
        branches = client.getBranches().getBranches();
    } else {
        branches = Collections.emptyList();
    }
    // OK
    return new GitSynchronisationInfo(gitConfiguration.getType(), gitConfiguration.getName(), gitConfiguration.getRemote(), gitConfiguration.getIndexationInterval(), status, branches);
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Example 12 with GitRepositoryClient

use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.

the class GitServiceImpl method index.

private void index(GitConfiguration config, JobRunListener listener) {
    listener.message("Git sync for %s", config.getName());
    // Gets the client for this configuration
    GitRepositoryClient client = gitRepositoryClientFactory.getClient(config.getGitRepository());
    // Launches the synchronisation
    client.sync(listener.logger());
}
Also used : GitRepositoryClient(net.nemerosa.ontrack.git.GitRepositoryClient)

Example 13 with GitRepositoryClient

use of net.nemerosa.ontrack.git.GitRepositoryClient in project ontrack by nemerosa.

the class GitServiceImpl method getChangeLogCommits.

@Override
public GitChangeLogCommits getChangeLogCommits(GitChangeLog changeLog) {
    // Gets the client
    GitRepositoryClient client = getGitRepositoryClient(changeLog.getProject());
    // Gets the build boundaries
    Build buildFrom = changeLog.getFrom().getBuild();
    Build buildTo = changeLog.getTo().getBuild();
    // Commit boundaries
    String commitFrom = getCommitFromBuild(buildFrom);
    String commitTo = getCommitFromBuild(buildTo);
    // Gets the commits
    GitLog log = client.graph(commitFrom, commitTo);
    // If log empty, inverts the boundaries
    if (log.getCommits().isEmpty()) {
        String t = commitFrom;
        commitFrom = commitTo;
        commitTo = t;
        log = client.graph(commitFrom, commitTo);
    }
    // Consolidation to UI
    List<GitCommit> commits = log.getCommits();
    List<GitUICommit> uiCommits = toUICommits(getRequiredProjectConfiguration(changeLog.getProject()), commits);
    return new GitChangeLogCommits(new GitUILog(log.getPlot(), uiCommits));
}
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