Search in sources :

Example 1 with EGitCredentialsProvider

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

the class SynchronizeFetchJob method runInWorkspace.

@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
    SubMonitor progress = SubMonitor.convert(monitor, gsdSet.size());
    progress.setTaskName(UIText.SynchronizeFetchJob_TaskName);
    for (GitSynchronizeData gsd : gsdSet) {
        Repository repo = gsd.getRepository();
        StoredConfig repoConfig = repo.getConfig();
        String remoteName = gsd.getDstRemoteName();
        if (remoteName == null) {
            progress.worked(1);
            continue;
        }
        progress.subTask(NLS.bind(UIText.SynchronizeFetchJob_SubTaskName, remoteName));
        RemoteConfig config;
        try {
            config = new RemoteConfig(repoConfig, remoteName);
        } catch (URISyntaxException e) {
            Activator.logError(e.getMessage(), e);
            progress.worked(1);
            continue;
        }
        FetchOperationUI fetchOperationUI = new FetchOperationUI(repo, config, timeout, false);
        fetchOperationUI.setCredentialsProvider(new EGitCredentialsProvider());
        try {
            fetchOperationUI.execute(progress.newChild(1));
            gsd.updateRevs();
        } catch (Exception e) {
            showInformationDialog(remoteName);
            Activator.logError(e.getMessage(), e);
        }
    }
    return Status.OK_STATUS;
}
Also used : StoredConfig(org.eclipse.jgit.lib.StoredConfig) GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) Repository(org.eclipse.jgit.lib.Repository) SubMonitor(org.eclipse.core.runtime.SubMonitor) URISyntaxException(java.net.URISyntaxException) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider) URISyntaxException(java.net.URISyntaxException) FetchOperationUI(org.eclipse.egit.ui.internal.fetch.FetchOperationUI)

Example 2 with EGitCredentialsProvider

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

the class RefSpecPage method revalidateImpl.

private void revalidateImpl(final RepositorySelection newRepoSelection) {
    final ListRemoteOperation listRemotesOp;
    try {
        final URIish uri;
        uri = newRepoSelection.getURI(pushPage);
        int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
        listRemotesOp = new ListRemoteOperation(local, uri, timeout);
        if (credentials != null)
            listRemotesOp.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                listRemotesOp.run(monitor);
            }
        });
    } catch (InvocationTargetException e) {
        final Throwable cause = e.getCause();
        transportError(cause.getMessage());
        Activator.handleError(UIText.RefSpecPage_errorTransportDialogMessage, cause, true);
        return;
    } catch (InterruptedException e) {
        transportError(UIText.RefSpecPage_operationCancelled);
        return;
    }
    this.validatedRepoSelection = newRepoSelection;
    specsPanel.setAssistanceData(local, listRemotesOp.getRemoteRefs(), currentRepoSelection.getConfig());
    if (newRepoSelection.isConfigSelected()) {
        saveButton.setVisible(true);
        saveButton.setText(NLS.bind(UIText.RefSpecPage_saveSpecifications, currentRepoSelection.getConfigName()));
        saveButton.getParent().layout();
        if (!pushPage) {
            tagsAutoFollowButton.setSelection(false);
            tagsFetchTagsButton.setSelection(false);
            tagsNoTagsButton.setSelection(false);
            final TagOpt tagOpt = newRepoSelection.getConfig().getTagOpt();
            switch(tagOpt) {
                case AUTO_FOLLOW:
                    tagsAutoFollowButton.setSelection(true);
                    break;
                case FETCH_TAGS:
                    tagsFetchTagsButton.setSelection(true);
                    break;
                case NO_TAGS:
                    tagsNoTagsButton.setSelection(true);
                    break;
            }
        }
    } else if (!pushPage)
        tagsAutoFollowButton.setSelection(true);
    checkPage();
}
Also used : URIish(org.eclipse.jgit.transport.URIish) ListRemoteOperation(org.eclipse.egit.core.op.ListRemoteOperation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TagOpt(org.eclipse.jgit.transport.TagOpt) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 3 with EGitCredentialsProvider

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

the class SourceBranchPage method revalidateImpl.

private void revalidateImpl(final RepositorySelection newRepoSelection) {
    if (label.isDisposed() || !isCurrentPage())
        return;
    final ListRemoteOperation listRemoteOp;
    final URIish uri = newRepoSelection.getURI();
    try {
        int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
        listRemoteOp = new ListRemoteOperation(uri, timeout);
        if (credentials != null)
            listRemoteOp.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                listRemoteOp.run(monitor);
            }
        });
    } catch (InvocationTargetException e) {
        Throwable why = e.getCause();
        transportError(why);
        if (showDetailedFailureDialog())
            SourceBranchFailureDialog.show(getShell(), uri);
        return;
    } catch (InterruptedException e) {
        transportError(UIText.SourceBranchPage_remoteListingCancelled);
        return;
    }
    final Ref idHEAD = listRemoteOp.getRemoteRef(Constants.HEAD);
    head = null;
    boolean headIsMaster = false;
    final String masterBranchRef = Constants.R_HEADS + Constants.MASTER;
    for (final Ref r : listRemoteOp.getRemoteRefs()) {
        final String n = r.getName();
        if (!n.startsWith(Constants.R_HEADS)) {
            continue;
        }
        availableRefs.add(r);
        if (idHEAD == null || headIsMaster) {
            continue;
        }
        ObjectId objectId = r.getObjectId();
        if (objectId == null) {
            continue;
        }
        if (objectId.equals(idHEAD.getObjectId())) {
            headIsMaster = masterBranchRef.equals(r.getName());
            if (head == null || headIsMaster) {
                head = r;
            }
        }
    }
    Collections.sort(availableRefs, new Comparator<Ref>() {

        @Override
        public int compare(final Ref o1, final Ref o2) {
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });
    if (idHEAD != null && head == null) {
        head = idHEAD;
        availableRefs.add(0, idHEAD);
    }
    validatedRepoSelection = newRepoSelection;
    refsViewer.setInput(availableRefs);
    refsViewer.setAllChecked(true);
    checkPage();
    checkForEmptyRepo();
}
Also used : URIish(org.eclipse.jgit.transport.URIish) ObjectId(org.eclipse.jgit.lib.ObjectId) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ListRemoteOperation(org.eclipse.egit.core.op.ListRemoteOperation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Ref(org.eclipse.jgit.lib.Ref)

Example 4 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider 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 5 with EGitCredentialsProvider

use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider 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

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