use of org.eclipse.jgit.errors.NotSupportedException in project egit by eclipse.
the class PushOperationUI method createPushOperation.
private void createPushOperation() throws CoreException {
if (remoteName != null) {
op = new PushOperation(repository, remoteName, dryRun, getTimeout());
return;
}
if (spec == null) {
// spec == null => config was supplied in constructor
// we don't use the configuration directly, as it may contain
// unsaved changes and as we may need
// to add the default push RefSpec here
spec = new PushOperationSpecification();
List<URIish> urisToPush = new ArrayList<>();
for (URIish uri : config.getPushURIs()) urisToPush.add(uri);
if (urisToPush.isEmpty() && !config.getURIs().isEmpty())
urisToPush.add(config.getURIs().get(0));
List<RefSpec> pushRefSpecs = new ArrayList<>();
pushRefSpecs.addAll(config.getPushRefSpecs());
for (URIish uri : urisToPush) {
try {
// Fetch ref specs are passed here to make sure that the
// returned remote ref updates include tracking branch
// updates.
Collection<RemoteRefUpdate> remoteRefUpdates = Transport.findRemoteRefUpdatesFor(repository, pushRefSpecs, config.getFetchRefSpecs());
spec.addURIRefUpdates(uri, remoteRefUpdates);
} catch (NotSupportedException e) {
throw new CoreException(Activator.createErrorStatus(e.getMessage(), e));
} catch (IOException e) {
throw new CoreException(Activator.createErrorStatus(e.getMessage(), e));
}
}
}
op = new PushOperation(repository, spec, dryRun, getTimeout());
}
use of org.eclipse.jgit.errors.NotSupportedException in project jbosstools-openshift by jbosstools.
the class EGitUtils method createPushSpec.
/**
* Creates a push operation specification for the given push uris to the
* given push operation specification.
*
* @param pushURIs
* the push uri's
* @param pushRefSpecs
* the push ref specs
* @param fetchRefSpecs
* @param repository
* the repository
* @return the push operation specification
* @throws CoreException
* the core exception
*/
private static PushOperationSpecification createPushSpec(Collection<URIish> pushURIs, Collection<RefSpec> pushRefSpecs, Collection<RefSpec> fetchRefSpecs, Repository repository) throws CoreException {
try {
PushOperationSpecification pushSpec = new PushOperationSpecification();
final Collection<RemoteRefUpdate> updates = Transport.findRemoteRefUpdatesFor(repository, pushRefSpecs, fetchRefSpecs);
if (updates.isEmpty()) {
throw new CoreException(new Status(IStatus.ERROR, EGitCoreActivator.PLUGIN_ID, "There's no local source ref that match the remote refs (local refs changed?)"));
}
for (URIish uri : pushURIs) {
pushSpec.addURIRefUpdates(uri, copy(updates));
}
return pushSpec;
} catch (NotSupportedException e) {
throw new CoreException(createStatus(e, "Could not connect repository \"{0}\" to a remote", repository.toString()));
} catch (IOException e) {
throw new CoreException(createStatus(e, "Could not convert remote specifications for repository \"{0}\" to a remote", repository.toString()));
}
}
Aggregations