use of org.eclipse.egit.core.op.PushOperationSpecification in project egit by eclipse.
the class ConfirmationPage method revalidateImpl.
private void revalidateImpl() {
if (getControl().isDisposed() || !isCurrentPage())
return;
final List<RefSpec> fetchSpecs;
if (displayedRepoSelection.isConfigSelected())
fetchSpecs = displayedRepoSelection.getConfig().getFetchRefSpecs();
else
fetchSpecs = null;
final PushOperation operation;
try {
final Collection<RemoteRefUpdate> updates = Transport.findRemoteRefUpdatesFor(local, displayedRefSpecs, fetchSpecs);
if (updates.isEmpty()) {
// It can happen only when local refs changed in the mean time.
setErrorMessage(UIText.ConfirmationPage_errorRefsChangedNoMatch);
setPageComplete(false);
return;
}
final PushOperationSpecification spec = new PushOperationSpecification();
for (final URIish uri : displayedRepoSelection.getPushURIs()) spec.addURIRefUpdates(uri, copyUpdates(updates));
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
operation = new PushOperation(local, spec, true, timeout);
if (credentials != null)
operation.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
operation.run(monitor);
}
});
} catch (final IOException e) {
setErrorMessage(NLS.bind(UIText.ConfirmationPage_errorCantResolveSpecs, e.getMessage()));
return;
} catch (final InvocationTargetException e) {
setErrorMessage(NLS.bind(UIText.ConfirmationPage_errorUnexpected, e.getCause().getMessage()));
return;
} catch (final InterruptedException e) {
setErrorMessage(UIText.ConfirmationPage_errorInterrupted);
setPageComplete(true);
displayedRefSpecs = null;
displayedRepoSelection = null;
return;
}
final PushOperationResult result = operation.getOperationResult();
resultPanel.setData(local, result);
if (result.isSuccessfulConnectionForAnyURI()) {
setPageComplete(true);
confirmedResult = result;
} else {
final String message = NLS.bind(UIText.ConfirmationPage_cantConnectToAny, result.getErrorStringForAllURis());
setErrorMessage(message);
ErrorDialog.openError(getShell(), UIText.ConfirmationPage_cantConnectToAnyTitle, null, new Status(IStatus.ERROR, Activator.getPluginId(), message));
}
}
use of org.eclipse.egit.core.op.PushOperationSpecification in project egit by eclipse.
the class PushToGerritPage method doPush.
void doPush() {
try {
URIish uri = new URIish(uriCombo.getText());
Ref currentHead = repository.exactRef(Constants.HEAD);
String ref = prefixCombo.getItem(prefixCombo.getSelectionIndex()) + branchText.getText().trim();
if (topicText.isEnabled()) {
ref = setTopicInRef(ref, topicText.getText().trim());
}
RemoteRefUpdate update = new RemoteRefUpdate(repository, currentHead, ref, false, null, null);
PushOperationSpecification spec = new PushOperationSpecification();
spec.addURIRefUpdates(uri, Arrays.asList(update));
final PushOperationUI op = new PushOperationUI(repository, spec, false);
storeLastUsedUri(uriCombo.getText());
storeLastUsedBranch(branchText.getText());
storeLastUsedTopic(topicText.isEnabled(), topicText.getText().trim(), repository.getBranch());
op.setPushMode(PushMode.GERRIT);
op.start();
} catch (URISyntaxException | IOException e) {
Activator.handleError(e.getMessage(), e, true);
}
}
Aggregations