use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.
the class EGitUtils method getAllRemoteURIs.
/**
* Returns all uris of alls remotes for the given project.
*
* @param project
* the project to get all remotes and all uris from
* @return all uris
* @throws CoreException
*/
public static List<URIish> getAllRemoteURIs(IProject project) throws CoreException {
List<RemoteConfig> remoteConfigs = getAllRemoteConfigs(getRepository(project));
List<URIish> uris = new ArrayList<>();
if (remoteConfigs != null) {
for (RemoteConfig remoteConfig : remoteConfigs) {
uris.addAll(remoteConfig.getURIs());
}
}
return uris;
}
use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.
the class EGitUtils method getRemoteConfig.
/**
* Gets the remote config with the given name from the list of remote
* configs. Returns <code>null</code> if it was not found.
*
* @param remoteName
* the remote name
* @param remoteRepositories
* the remote repositories
* @return the remote config
*
* @see #getAllRemoteConfigs(Repository)
*/
public static RemoteConfig getRemoteConfig(String name, List<RemoteConfig> remoteConfigs) {
Assert.isLegal(name != null);
RemoteConfig remoteConfig = null;
for (RemoteConfig config : remoteConfigs) {
if (name != null && config.getName().equals(name)) {
remoteConfig = config;
break;
}
}
return remoteConfig;
}
use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.
the class EGitUtils method getRemoteGitReposFilteredStream.
private static Stream<String> getRemoteGitReposFilteredStream(IProject project) throws CoreException {
if (project == null) {
return null;
}
Repository repo = getRepository(project);
if (repo == null) {
return null;
}
// Returned configurations are ordered lexicographically by names.
List<RemoteConfig> remoteConfigs = getAllRemoteConfigs(repo);
Collections.sort(remoteConfigs, new Comparator<RemoteConfig>() {
@Override
public int compare(RemoteConfig o1, RemoteConfig o2) {
if (ORIGIN.equals(o1.getName())) {
return -1;
}
if (ORIGIN.equals(o2.getName())) {
return 1;
}
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
return remoteConfigs.stream().map(rc -> getFetchURI(rc)).filter(uri -> uri != null && uri.toString().startsWith("http")).map(URIish::toString);
}
Aggregations