Search in sources :

Example 6 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.

the class PushOperationUI method start.

/**
 * Starts the operation asynchronously.
 */
public void start() {
    final Repository repo = repository;
    if (repo == null) {
        return;
    }
    try {
        createPushOperation();
    } catch (CoreException e) {
        Activator.showErrorStatus(e.getLocalizedMessage(), e.getStatus());
        return;
    }
    if (credentialsProvider != null) {
        op.setCredentialsProvider(credentialsProvider);
    } else {
        op.setCredentialsProvider(new EGitCredentialsProvider());
    }
    Job job = new PushJob(NLS.bind(UIText.PushOperationUI_PushJobName, destinationString), repo, op, expectedResult, destinationString, showConfigureButton, pushMode);
    job.setUser(true);
    job.schedule();
}
Also used : Repository(org.eclipse.jgit.lib.Repository) CoreException(org.eclipse.core.runtime.CoreException) Job(org.eclipse.core.runtime.jobs.Job) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)

Example 7 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.

the class FetchWizard method performFinish.

@Override
public boolean performFinish() {
    boolean calledFromRepoPage = false;
    if (getContainer().getCurrentPage() == repoPage)
        calledFromRepoPage = true;
    if (repoPage.getSelection().isConfigSelected() && refSpecPage.isSaveRequested())
        saveConfig();
    if (repoPage.getStoreInSecureStore()) {
        if (!SecureStoreUtils.storeCredentials(repoPage.getCredentials(), repoPage.getSelection().getURI()))
            return false;
    }
    final FetchOperationUI op;
    int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
    final RepositorySelection repoSelection = repoPage.getSelection();
    if (calledFromRepoPage)
        op = new FetchOperationUI(localDb, repoSelection.getConfig(), timeout, false);
    else if (repoSelection.isConfigSelected())
        op = new FetchOperationUI(localDb, repoSelection.getConfig().getURIs().get(0), refSpecPage.getRefSpecs(), timeout, false);
    else
        op = new FetchOperationUI(localDb, repoSelection.getURI(false), refSpecPage.getRefSpecs(), timeout, false);
    UserPasswordCredentials credentials = repoPage.getCredentials();
    if (credentials != null)
        op.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
    // add the RefSpecs from the RefSpec page into the FetchOperation
    if (!calledFromRepoPage)
        op.setTagOpt(refSpecPage.getTagOpt());
    op.start();
    repoPage.saveUriInPrefs();
    return true;
}
Also used : RepositorySelection(org.eclipse.egit.ui.internal.components.RepositorySelection) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider) UserPasswordCredentials(org.eclipse.egit.core.securestorage.UserPasswordCredentials)

Example 8 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.

the class PushAction method runPushOperation.

private void runPushOperation() {
    GitSynchronizeDataSet gsds = (GitSynchronizeDataSet) getConfiguration().getProperty(SYNCHRONIZATION_DATA);
    for (GitSynchronizeData gsd : gsds) {
        String remoteName = gsd.getDstRemoteName();
        if (remoteName == null)
            continue;
        RemoteConfig rc;
        Repository repo = gsd.getRepository();
        StoredConfig config = repo.getConfig();
        try {
            rc = new RemoteConfig(config, remoteName);
        } catch (URISyntaxException e) {
            Activator.logError("Unable to create RemoteConfiguration for remote: " + remoteName, // $NON-NLS-1$
            e);
            continue;
        }
        if (rc.getPushRefSpecs().isEmpty())
            // $NON-NLS-1$
            rc.addPushRefSpec(new RefSpec(HEAD + ":" + gsd.getDstMerge()));
        PushOperationUI push = new PushOperationUI(repo, rc, false);
        push.setCredentialsProvider(new EGitCredentialsProvider());
        push.start();
    }
}
Also used : StoredConfig(org.eclipse.jgit.lib.StoredConfig) GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) Repository(org.eclipse.jgit.lib.Repository) RefSpec(org.eclipse.jgit.transport.RefSpec) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) URISyntaxException(java.net.URISyntaxException) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)

Example 9 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider 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));
    }
}
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) IOException(java.io.IOException) PushOperation(org.eclipse.egit.core.op.PushOperation) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RefSpec(org.eclipse.jgit.transport.RefSpec) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification)

Example 10 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.

the class PushWizard method performFinish.

@Override
public boolean performFinish() {
    boolean calledFromRepoPage = false;
    if (getContainer().getCurrentPage() == repoPage)
        calledFromRepoPage = true;
    if (repoPage.getSelection().isConfigSelected() && refSpecPage.isSaveRequested()) {
        saveRefSpecs();
    }
    if (repoPage.getStoreInSecureStore()) {
        if (!SecureStoreUtils.storeCredentials(repoPage.getCredentials(), repoPage.getSelection().getURI()))
            return false;
    }
    final PushOperation operation = createPushOperation(calledFromRepoPage);
    if (operation == null)
        return false;
    UserPasswordCredentials credentials = repoPage.getCredentials();
    if (credentials != null)
        operation.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
    final PushOperationResult resultToCompare;
    if (confirmPage.isShowOnlyIfChangedSelected()) {
        resultToCompare = confirmPage.getConfirmedResult();
    } else {
        resultToCompare = null;
    }
    final Job job = new PushJob(NLS.bind(UIText.PushWizard_jobName, getURIsString(operation.getSpecification().getURIs())), localDb, operation, resultToCompare, getDestinationString(repoPage.getSelection()), true, PushMode.UPSTREAM);
    job.setUser(true);
    job.schedule();
    repoPage.saveUriInPrefs();
    return true;
}
Also used : PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) PushOperation(org.eclipse.egit.core.op.PushOperation) Job(org.eclipse.core.runtime.jobs.Job) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider) UserPasswordCredentials(org.eclipse.egit.core.securestorage.UserPasswordCredentials)

Aggregations

EGitCredentialsProvider (org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 PushOperationResult (org.eclipse.egit.core.op.PushOperationResult)4 Repository (org.eclipse.jgit.lib.Repository)4 URIish (org.eclipse.jgit.transport.URIish)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 PushOperationSpecification (org.eclipse.egit.core.op.PushOperationSpecification)3 UserPasswordCredentials (org.eclipse.egit.core.securestorage.UserPasswordCredentials)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 URISyntaxException (java.net.URISyntaxException)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 Job (org.eclipse.core.runtime.jobs.Job)2 ListRemoteOperation (org.eclipse.egit.core.op.ListRemoteOperation)2 PushOperation (org.eclipse.egit.core.op.PushOperation)2 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)2 Ref (org.eclipse.jgit.lib.Ref)2 StoredConfig (org.eclipse.jgit.lib.StoredConfig)2 RefSpec (org.eclipse.jgit.transport.RefSpec)2