Example usage for org.eclipse.jgit.api SubmoduleUpdateCommand call

List of usage examples for org.eclipse.jgit.api SubmoduleUpdateCommand call

Introduction

In this page you can find the example usage for org.eclipse.jgit.api SubmoduleUpdateCommand call.

Prototype

@Override
public Collection<String> call()
        throws InvalidConfigurationException, NoHeadException, ConcurrentRefUpdateException,
        CheckoutConflictException, InvalidMergeHeadsException, WrongRepositoryStateException,
        NoMessageException, NoHeadException, RefNotFoundException, GitAPIException 

Source Link

Document

Execute the SubmoduleUpdateCommand command.

Usage

From source file:edu.tum.cs.mylyn.provisioning.git.ui.GitProvisioningWizard.java

License:Open Source License

private void pull(Repository repository) throws IOException {
    Git git = new Git(repository);
    PullCommand pull = git.pull();/*from   w  w  w.  j av a2s .c om*/
    pull.setCredentialsProvider(new EGitCredentialsProvider());
    try {
        pull.call();
    } catch (TransportException e) {
        throw new IOException(e);
    } catch (GitAPIException e) {
        throw new IOException(e);
    }

    SubmoduleUpdateCommand update = git.submoduleUpdate();
    try {
        update.call();
    } catch (Exception e) {
        throw new IOException(e);
    }
}

From source file:org.eclipse.egit.core.op.SubmoduleUpdateOperation.java

License:Open Source License

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

        public void run(IProgressMonitor pm) throws CoreException {
            pm.beginTask("", 3); //$NON-NLS-1$
            Git git = Git.wrap(repository);

            Collection<String> updated = null;
            try {
                SubmoduleInitCommand init = git.submoduleInit();
                for (String path : paths)
                    init.addPath(path);//from   w ww  .ja va 2 s  . c  om
                init.call();
                pm.worked(1);

                SubmoduleUpdateCommand update = git.submoduleUpdate();
                for (String path : paths)
                    update.addPath(path);
                update.setProgressMonitor(new EclipseGitProgressTransformer(new SubProgressMonitor(pm, 2)));
                updated = update.call();
                pm.worked(1);
                SubProgressMonitor refreshMonitor = new SubProgressMonitor(pm, 1);
                refreshMonitor.beginTask("", updated.size()); //$NON-NLS-1$
                for (String path : updated) {
                    Repository subRepo = SubmoduleWalk.getSubmoduleRepository(repository, path);
                    if (subRepo != null)
                        ProjectUtil.refreshValidProjects(ProjectUtil.getValidOpenProjects(subRepo),
                                new SubProgressMonitor(refreshMonitor, 1));
                    else
                        refreshMonitor.worked(1);
                }
                refreshMonitor.done();
            } catch (GitAPIException e) {
                throw new TeamException(e.getLocalizedMessage(), e.getCause());
            } catch (IOException e) {
                throw new TeamException(e.getLocalizedMessage(), e.getCause());
            } finally {
                if (updated != null && !updated.isEmpty())
                    repository.notifyIndexChanged();
                pm.done();
            }
        }
    };
    ResourcesPlugin.getWorkspace().run(action, monitor != null ? monitor : new NullProgressMonitor());
}

From source file:org.eclipse.n4js.utils.git.GitUtils.java

License:Open Source License

/**
 * Update the submodules with the given repository-relative <code>submodulePaths</code> inside the Git repository at
 * the given clone path. Throws exceptions in case of error.
 *
 * @param submodulePaths/* w  w  w  .j  a  v  a  2 s .c o m*/
 *            repository-relative paths of the submodules to update; if empty, all submodules will be updated.
 */
public static void updateSubmodules(final Path localClonePath, final Iterable<String> submodulePaths,
        final IProgressMonitor monitor) {

    if (!isValidLocalClonePath(localClonePath)) {
        throw new IllegalArgumentException("invalid localClonePath: " + localClonePath);
    }

    @SuppressWarnings("restriction")
    final ProgressMonitor gitMonitor = null == monitor ? createMonitor()
            : new org.eclipse.egit.core.EclipseGitProgressTransformer(monitor);

    try (final Git git = open(localClonePath.toFile())) {
        final SubmoduleUpdateCommand cmd = git.submoduleUpdate();
        for (String submodulePath : submodulePaths) {
            cmd.addPath(submodulePath);
        }
        cmd.setProgressMonitor(gitMonitor);
        cmd.setTransportConfigCallback(TRANSPORT_CALLBACK);
        cmd.call();
    } catch (Exception e) {
        LOGGER.error(e.getClass().getSimpleName() + " while trying to update submodules "
                + Iterables.toString(submodulePaths) + " of repository '" + localClonePath + "':"
                + e.getLocalizedMessage());
        Throwables.throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}

From source file:org.eclipse.oomph.setup.git.impl.GitCloneTaskImpl.java

License:Open Source License

private static void addSubmodules(SetupTaskContext context, Git git, SubProgressMonitor monitor)
        throws Exception {
    context.log("Adding submodules");

    git.submoduleInit().call();//from w  w  w.j  av  a  2s  .c  o m

    SubmoduleUpdateCommand updateCommand = git.submoduleUpdate();
    updateCommand.setProgressMonitor(new EclipseGitProgressTransformer(monitor));
    updateCommand.call();
}

From source file:org.eclipse.orion.server.git.servlets.GitSubmoduleHandlerV1.java

License:Open Source License

public static boolean updateSubmodules(Repository repo) throws GitAPIException {
    SubmoduleInitCommand init = new SubmoduleInitCommand(repo);
    init.call();//from  w ww. ja va2s .c  om
    SubmoduleUpdateCommand update = new SubmoduleUpdateCommand(repo);
    Collection<String> updated = update.call();
    SubmoduleStatusCommand status = new SubmoduleStatusCommand(repo);
    Map<String, SubmoduleStatus> statusResult = status.call();
    return updated.size() == statusResult.size();
}