Java Code Examples for org.eclipse.jgit.api.SubmoduleUpdateCommand#call()

The following examples show how to use org.eclipse.jgit.api.SubmoduleUpdateCommand#call() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitUtils.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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
 *            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);
	}
}
 
Example 2
Source File: GitSubmoduleHandlerV1.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean updateSubmodules(Repository repo) throws GitAPIException {
	SubmoduleInitCommand init = new SubmoduleInitCommand(repo);
	init.call();
	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();
}