Search in sources :

Example 1 with PushOperationSpecification

use of org.eclipse.egit.core.op.PushOperationSpecification in project egit by eclipse.

the class PushOperationTest method createInvalidPushOperation.

private PushOperation createInvalidPushOperation() throws Exception {
    // set up push with invalid URI to provoke an exception
    PushOperationSpecification spec = new PushOperationSpecification();
    // the remote is invalid
    URIish remote = new URIish(INVALID_URI);
    // update master upon master
    Repository local = repository1.getRepository();
    RemoteRefUpdate update = new RemoteRefUpdate(local, "HEAD", "refs/heads/test", false, null, null);
    spec.addURIRefUpdates(remote, Collections.singletonList(update));
    // now we can construct the push operation
    PushOperation pop = new PushOperation(local, spec, false, 0);
    return pop;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) TestRepository(org.eclipse.egit.core.test.TestRepository) Repository(org.eclipse.jgit.lib.Repository) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) PushOperation(org.eclipse.egit.core.op.PushOperation)

Example 2 with PushOperationSpecification

use of org.eclipse.egit.core.op.PushOperationSpecification in project egit by eclipse.

the class PushOperationTest method createPushOperation.

private PushOperation createPushOperation() throws Exception {
    // set up push from repository1 to repository2
    // we cannot re-use the RemoteRefUpdate!!!
    PushOperationSpecification spec = new PushOperationSpecification();
    // the remote is repo2
    URIish remote = new URIish("file:///" + repository2.getRepository().getDirectory().toString());
    // update master upon master
    List<RemoteRefUpdate> refUpdates = new ArrayList<RemoteRefUpdate>();
    RemoteRefUpdate update = new RemoteRefUpdate(repository1.getRepository(), "HEAD", "refs/heads/test", false, null, null);
    refUpdates.add(update);
    spec.addURIRefUpdates(remote, refUpdates);
    // now we can construct the push operation
    PushOperation pop = new PushOperation(repository1.getRepository(), spec, false, 0);
    return pop;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ArrayList(java.util.ArrayList) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) PushOperation(org.eclipse.egit.core.op.PushOperation)

Example 3 with PushOperationSpecification

use of org.eclipse.egit.core.op.PushOperationSpecification 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 PushOperationSpecification

use of org.eclipse.egit.core.op.PushOperationSpecification 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 PushOperationSpecification

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

Aggregations

PushOperationSpecification (org.eclipse.egit.core.op.PushOperationSpecification)12 URIish (org.eclipse.jgit.transport.URIish)10 RemoteRefUpdate (org.eclipse.jgit.transport.RemoteRefUpdate)9 PushOperation (org.eclipse.egit.core.op.PushOperation)8 IOException (java.io.IOException)5 PushOperationResult (org.eclipse.egit.core.op.PushOperationResult)5 ArrayList (java.util.ArrayList)4 RefSpec (org.eclipse.jgit.transport.RefSpec)4 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 EGitCredentialsProvider (org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)3 CoreException (org.eclipse.core.runtime.CoreException)2 NotSupportedException (org.eclipse.jgit.errors.NotSupportedException)2 Test (org.junit.Test)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 Collection (java.util.Collection)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1