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);
}
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());
}
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));
}
Aggregations