use of org.eclipse.che.api.git.shared.RemoteReference in project che by eclipse.
the class LsRemoteTest method testShouldBeAbleToGetResultFromPublicRepo.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testShouldBeAbleToGetResultFromPublicRepo(GitConnectionFactory connectionFactory) throws GitException, IOException, UnauthorizedException {
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
//when
Set<RemoteReference> remoteReferenceSet = new HashSet<>(connection.lsRemote("https://github.com/codenvy/everrest.git"));
//then
assertTrue(remoteReferenceSet.contains(newDto(RemoteReference.class).withCommitId("259e24c83c8a122af858c8306c3286586404ef3f").withReferenceName("refs/tags/1.1.9")));
}
use of org.eclipse.che.api.git.shared.RemoteReference in project che by eclipse.
the class JGitConnection method lsRemote.
@Override
public List<RemoteReference> lsRemote(String remoteUrl) throws UnauthorizedException, GitException {
LsRemoteCommand lsRemoteCommand = getGit().lsRemote().setRemote(remoteUrl);
Collection<Ref> refs;
try {
refs = lsRemoteCommand.call();
} catch (GitAPIException exception) {
if (exception.getMessage().contains(ERROR_AUTHENTICATION_REQUIRED)) {
throw new UnauthorizedException(format(ERROR_AUTHENTICATION_FAILED, remoteUrl));
} else {
throw new GitException(exception.getMessage(), exception);
}
}
return refs.stream().map(ref -> newDto(RemoteReference.class).withCommitId(ref.getObjectId().name()).withReferenceName(ref.getName())).collect(Collectors.toList());
}
Aggregations