use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class PushBranchWizard method startPush.
private void startPush() throws IOException {
PushOperationResult result = confirmationPage.getConfirmedResult();
PushOperationSpecification pushSpec = result.deriveSpecification(confirmationPage.isRequireUnchangedSelected());
PushOperationUI pushOperationUI = new PushOperationUI(repository, pushSpec, false);
pushOperationUI.setCredentialsProvider(new EGitCredentialsProvider());
pushOperationUI.setShowConfigureButton(false);
if (confirmationPage.isShowOnlyIfChangedSelected())
pushOperationUI.setExpectedResult(result);
pushOperationUI.start();
}
use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class PushResultTable method getResult.
private String getResult(RefUpdateElement element) {
StringBuilder result = new StringBuilder(EMPTY_STRING);
PushOperationResult pushOperationResult = element.getPushOperationResult();
final URIish uri = element.getUri();
result.append(UIText.PushResultTable_repository);
result.append(SPACE);
result.append(uri.toString());
result.append(Text.DELIMITER);
result.append(Text.DELIMITER);
String message = element.getRemoteRefUpdate().getMessage();
if (message != null)
result.append(message).append(Text.DELIMITER);
StringBuilder messagesBuffer = new StringBuilder(pushOperationResult.getPushResult(uri).getMessages());
trim(messagesBuffer);
if (messagesBuffer.length() > 0)
result.append(messagesBuffer).append(Text.DELIMITER);
trim(result);
return result.toString();
}
use of org.eclipse.egit.core.op.PushOperationResult in project jbosstools-openshift by jbosstools.
the class EGitUtils method push.
private static PushOperationResult push(Repository repository, RemoteConfig remoteConfig, boolean force, IProgressMonitor monitor, OutputStream out) throws CoreException {
try {
if (remoteConfig == null) {
throw new CoreException(createStatus(null, "Repository \"{0}\" has no remote repository configured", repository.toString()));
}
PushOperation op = createPushOperation(remoteConfig, repository, force, out);
op.run(monitor);
PushOperationResult pushResult = op.getOperationResult();
if (hasFailedEntries(pushResult)) {
throw new CoreException(EGitCoreActivator.createErrorStatus(NLS.bind("Could not push repository {0}: {1}", repository.toString(), getErrors(pushResult)), null));
}
return pushResult;
} catch (CoreException e) {
throw e;
} catch (Exception e) {
throw new CoreException(createStatus(e, "Could not push repo {0}", repository.toString()));
}
}
use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class PushOperationTest method testUpdateTrackingBranchIfSpecifiedInRemoteRefUpdate.
@Test
public void testUpdateTrackingBranchIfSpecifiedInRemoteRefUpdate() throws Exception {
// Commit on repository 2
IProject project = importProject(repository2, projectName);
RevCommit commit = repository2.addAndCommit(project, new File(workdir2, "test.txt"), "Commit in repository 2");
project.delete(false, false, null);
// We want to push from repository 2 to 1 (because repository 2 already
// has tracking set up)
URIish remote = repository1.getUri();
String trackingRef = "refs/remotes/origin/master";
RemoteRefUpdate update = new RemoteRefUpdate(repository2.getRepository(), "HEAD", "refs/heads/master", false, trackingRef, null);
PushOperationSpecification spec = new PushOperationSpecification();
spec.addURIRefUpdates(remote, Arrays.asList(update));
PushOperation push = new PushOperation(repository2.getRepository(), spec, false, 0);
push.run(null);
PushOperationResult result = push.getOperationResult();
PushResult pushResult = result.getPushResult(remote);
assertNotNull("Expected result to have tracking ref update", pushResult.getTrackingRefUpdate(trackingRef));
ObjectId trackingId = repository2.getRepository().resolve(trackingRef);
assertEquals("Expected tracking branch to be updated", commit.getId(), trackingId);
}
use of org.eclipse.egit.core.op.PushOperationResult 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));
}
}
Aggregations