Search in sources :

Example 11 with EclipseGitProgressTransformer

use of org.eclipse.egit.core.EclipseGitProgressTransformer in project egit by eclipse.

the class SubmoduleAddOperation method execute.

@Override
public void execute(IProgressMonitor monitor) throws CoreException {
    IWorkspaceRunnable action = new IWorkspaceRunnable() {

        @Override
        public void run(IProgressMonitor pm) throws CoreException {
            final SubmoduleAddCommand add = Git.wrap(repo).submoduleAdd();
            add.setProgressMonitor(new EclipseGitProgressTransformer(pm));
            add.setPath(path);
            add.setURI(uri);
            try {
                Repository subRepo = add.call();
                if (subRepo != null) {
                    subRepo.close();
                    repo.notifyIndexChanged();
                }
            } catch (GitAPIException e) {
                throw new TeamException(e.getLocalizedMessage(), e.getCause());
            }
        }
    };
    ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, monitor);
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Repository(org.eclipse.jgit.lib.Repository) SubmoduleAddCommand(org.eclipse.jgit.api.SubmoduleAddCommand) EclipseGitProgressTransformer(org.eclipse.egit.core.EclipseGitProgressTransformer)

Example 12 with EclipseGitProgressTransformer

use of org.eclipse.egit.core.EclipseGitProgressTransformer in project egit by eclipse.

the class FetchOperation method run.

/**
 * @param monitor
 * @throws InvocationTargetException
 */
public void run(IProgressMonitor monitor) throws InvocationTargetException {
    if (operationResult != null)
        throw new IllegalStateException(CoreText.OperationAlreadyExecuted);
    EclipseGitProgressTransformer gitMonitor = new EclipseGitProgressTransformer(monitor);
    try (Git git = new Git(repository)) {
        FetchCommand command;
        if (rc == null)
            command = git.fetch().setRemote(uri.toPrivateString()).setRefSpecs(specs);
        else
            command = git.fetch().setRemote(rc.getName());
        command.setCredentialsProvider(credentialsProvider).setTimeout(timeout).setDryRun(dryRun).setProgressMonitor(gitMonitor);
        if (tagOpt != null)
            command.setTagOpt(tagOpt);
        try {
            operationResult = command.call();
        } catch (JGitInternalException e) {
            throw new InvocationTargetException(e.getCause() != null ? e.getCause() : e);
        } catch (Exception e) {
            throw new InvocationTargetException(e);
        }
    }
}
Also used : Git(org.eclipse.jgit.api.Git) FetchCommand(org.eclipse.jgit.api.FetchCommand) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException) EclipseGitProgressTransformer(org.eclipse.egit.core.EclipseGitProgressTransformer) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException)

Aggregations

EclipseGitProgressTransformer (org.eclipse.egit.core.EclipseGitProgressTransformer)12 SubMonitor (org.eclipse.core.runtime.SubMonitor)7 Git (org.eclipse.jgit.api.Git)7 IProject (org.eclipse.core.resources.IProject)5 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)5 CoreException (org.eclipse.core.runtime.CoreException)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)5 JGitInternalException (org.eclipse.jgit.api.errors.JGitInternalException)4 Repository (org.eclipse.jgit.lib.Repository)4 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 IndexDiff (org.eclipse.jgit.lib.IndexDiff)3 MergeStrategy (org.eclipse.jgit.merge.MergeStrategy)3 Collection (java.util.Collection)2 CloneCommand (org.eclipse.jgit.api.CloneCommand)2 AnyObjectId (org.eclipse.jgit.lib.AnyObjectId)2 Ref (org.eclipse.jgit.lib.Ref)2