use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class PushOperationTest method testInvalidUriDuringPush.
/**
* An invalid URI should yield an operation result with an error message
* and the exception should be logged
*
* @throws Exception
*/
@Test
public void testInvalidUriDuringPush() throws Exception {
ILog log = Activator.getDefault().getLog();
LogListener listener = new LogListener();
log.addLogListener(listener);
PushOperation pop = createInvalidPushOperation();
pop.run(new NullProgressMonitor());
PushOperationResult result = pop.getOperationResult();
String errorMessage = result.getErrorMessage(new URIish(INVALID_URI));
assertNotNull(errorMessage);
assertTrue(errorMessage.contains(INVALID_URI));
assertTrue(listener.loggedSomething());
assertTrue(listener.loggedException());
}
use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class CurrentBranchPublishOperationTest method testFeaturePublish.
@Test
public void testFeaturePublish() throws Exception {
new InitOperation(repository2.getRepository()).execute(null);
GitFlowRepository gfRepo2 = new GitFlowRepository(repository2.getRepository());
new FeatureStartOperation(gfRepo2, MY_FEATURE).execute(null);
RevCommit branchCommit = repository2.createInitialCommit("testFeaturePublish");
CurrentBranchPublishOperation featurePublishOperation = new CurrentBranchPublishOperation(gfRepo2, 0);
featurePublishOperation.execute(null);
PushOperationResult result = featurePublishOperation.getOperationResult();
assertTrue(result.isSuccessfulConnection(repository1.getUri()));
PushResult pushResult = result.getPushResult(repository1.getUri());
assertEquals(RefUpdate.Result.NEW, pushResult.getTrackingRefUpdates().iterator().next().getResult());
assertCommitArrivedAtRemote(branchCommit, repository1.getRepository());
// config updated?
assertEquals(DEFAULT_REMOTE_NAME, getRemoteName(gfRepo2, MY_FEATURE));
assertEquals(R_HEADS + gfRepo2.getConfig().getFeatureBranchName(MY_FEATURE), gfRepo2.getUpstreamBranchName(MY_FEATURE));
}
use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class PushTagsWizard 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(confirmationPage.getConfirmedResult());
pushOperationUI.start();
}
use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class PushWizard method createPushOperation.
private PushOperation createPushOperation(boolean calledFromRepoPage) {
try {
final PushOperationSpecification spec;
final RemoteConfig config = repoPage.getSelection().getConfig();
if (calledFromRepoPage) {
// obtain the push ref specs from the configuration
// use our own list here, as the config returns a non-modifiable
// list
final Collection<RefSpec> pushSpecs = new ArrayList<>();
pushSpecs.addAll(config.getPushRefSpecs());
final Collection<RemoteRefUpdate> updates = Transport.findRemoteRefUpdatesFor(localDb, pushSpecs, config.getFetchRefSpecs());
spec = new PushOperationSpecification();
for (final URIish uri : repoPage.getSelection().getPushURIs()) spec.addURIRefUpdates(uri, ConfirmationPage.copyUpdates(updates));
} else if (confirmPage.isConfirmed()) {
final PushOperationResult confirmedResult = confirmPage.getConfirmedResult();
spec = confirmedResult.deriveSpecification(confirmPage.isRequireUnchangedSelected());
} else {
final Collection<RefSpec> fetchSpecs;
if (config != null)
fetchSpecs = config.getFetchRefSpecs();
else
fetchSpecs = null;
final Collection<RemoteRefUpdate> updates = Transport.findRemoteRefUpdatesFor(localDb, refSpecPage.getRefSpecs(), fetchSpecs);
if (updates.isEmpty()) {
ErrorDialog.openError(getShell(), UIText.PushWizard_missingRefsTitle, null, new Status(IStatus.ERROR, Activator.getPluginId(), UIText.PushWizard_missingRefsMessage));
return null;
}
spec = new PushOperationSpecification();
for (final URIish uri : repoPage.getSelection().getPushURIs()) spec.addURIRefUpdates(uri, ConfirmationPage.copyUpdates(updates));
}
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
return new PushOperation(localDb, spec, false, timeout);
} catch (final IOException e) {
ErrorDialog.openError(getShell(), UIText.PushWizard_cantPrepareUpdatesTitle, UIText.PushWizard_cantPrepareUpdatesMessage, new Status(IStatus.ERROR, Activator.getPluginId(), e.getMessage(), e));
return null;
}
}
use of org.eclipse.egit.core.op.PushOperationResult in project egit by eclipse.
the class SimpleConfigurePushDialog method dryRun.
@Override
protected void dryRun(IProgressMonitor monitor) {
PushOperationUI op = new PushOperationUI(getRepository(), getConfig(), true);
try {
final PushOperationResult result = op.execute(monitor);
getShell().getDisplay().asyncExec(() -> {
PushResultDialog dlg = new PushResultDialog(getShell(), getRepository(), result, op.getDestinationString(), true, PushMode.UPSTREAM);
dlg.showConfigureButton(false);
dlg.open();
});
} catch (CoreException e) {
Activator.handleError(e.getMessage(), e, true);
}
}
Aggregations