Search in sources :

Example 1 with PushOperationResult

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());
}
Also used : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) URIish(org.eclipse.jgit.transport.URIish) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILogListener(org.eclipse.core.runtime.ILogListener) ILog(org.eclipse.core.runtime.ILog) PushOperation(org.eclipse.egit.core.op.PushOperation) Test(org.junit.Test)

Example 2 with PushOperationResult

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));
}
Also used : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) PushResult(org.eclipse.jgit.transport.PushResult) GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 3 with PushOperationResult

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();
}
Also used : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)

Example 4 with PushOperationResult

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;
    }
}
Also used : RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) URIish(org.eclipse.jgit.transport.URIish) PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PushOperation(org.eclipse.egit.core.op.PushOperation) RefSpec(org.eclipse.jgit.transport.RefSpec) Collection(java.util.Collection) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 5 with PushOperationResult

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);
    }
}
Also used : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

PushOperationResult (org.eclipse.egit.core.op.PushOperationResult)11 PushOperation (org.eclipse.egit.core.op.PushOperation)6 PushOperationSpecification (org.eclipse.egit.core.op.PushOperationSpecification)5 URIish (org.eclipse.jgit.transport.URIish)5 EGitCredentialsProvider (org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)4 IOException (java.io.IOException)3 RemoteRefUpdate (org.eclipse.jgit.transport.RemoteRefUpdate)3 Test (org.junit.Test)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 PushResult (org.eclipse.jgit.transport.PushResult)2 RefSpec (org.eclipse.jgit.transport.RefSpec)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1