org.eclipse.jgit.submodule.SubmoduleStatus Java Examples

The following examples show how to use org.eclipse.jgit.submodule.SubmoduleStatus. 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 6 votes vote down vote up
/**
 * Obtain information about all submodules of the Git repository at the given path. Returns an empty map in case the
 * repository does not include submodules. Throws exceptions in case of error.
 */
public static Map<String, SubmoduleStatus> getSubmodules(final Path localClonePath) {

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

	try (final Git git = open(localClonePath.toFile())) {
		return git.submoduleStatus().call();
	} catch (Exception e) {
		LOGGER.error(e.getClass().getSimpleName()
				+ " while trying to obtain status of all submodules"
				+ " of repository '" + localClonePath
				+ "':" + e.getLocalizedMessage());
		Throwables.throwIfUnchecked(e);
		throw new RuntimeException(e);
	}
}
 
Example #2
Source File: SubmoduleStatusCommand.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    File workTree = repository.getWorkTree();
    org.eclipse.jgit.api.SubmoduleStatusCommand cmd = new Git(repository).submoduleStatus();
    for (String path : Utils.getRelativePaths(workTree, roots)) {
        cmd.addPath(path);
    }
    try {
        Map<String, SubmoduleStatus> result = cmd.call();
        GitClassFactory fac = getClassFactory();
        for (Map.Entry<String, SubmoduleStatus> e : result.entrySet()) {
            File root = new File(workTree, e.getKey());
            statuses.put(root, fac.createSubmoduleStatus(e.getValue(), root));
        }
    } catch (GitAPIException | JGitInternalException ex) {
        throw new GitException(ex);
    }
}
 
Example #3
Source File: JGitHelper.java    From go-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void printSubmoduleStatus() {
    Repository repository = null;
    try {
        repository = getRepository(workingDir);
        Git git = new Git(repository);
        SubmoduleStatusCommand submoduleStatus = git.submoduleStatus();
        Map<String, SubmoduleStatus> submoduleStatusMap = submoduleStatus.call();
        for (String submoduleFolder : submoduleStatusMap.keySet()) {
            // print
        }
    } catch (Exception e) {
        throw new RuntimeException("sub-module print status failed", e);
    } finally {
        if (repository != null) {
            repository.close();
        }
    }
}
 
Example #4
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();
}
 
Example #5
Source File: GitSubmoduleHandlerV1.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean syncSubmodules(Repository repo) throws GitAPIException {
	SubmoduleSyncCommand sync = new SubmoduleSyncCommand(repo);
	Map<String, String> synced = sync.call();
	SubmoduleStatusCommand status = new SubmoduleStatusCommand(repo);
	Map<String, SubmoduleStatus> statusResult = status.call();
	return synced.size() == statusResult.size();
}
 
Example #6
Source File: GitClassFactoryImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public GitSubmoduleStatus createSubmoduleStatus (SubmoduleStatus status, File folder) {
    return new GitSubmoduleStatus(status, folder);
}
 
Example #7
Source File: GitSubmoduleStatus.java    From netbeans with Apache License 2.0 2 votes vote down vote up
GitSubmoduleStatus (SubmoduleStatus delegate, File folder) {
    this.delegate = delegate;
    this.folder = folder;
    this.statusType = parseStatus(delegate.getType());
}
 
Example #8
Source File: GitClassFactory.java    From netbeans with Apache License 2.0 votes vote down vote up
public abstract GitSubmoduleStatus createSubmoduleStatus (SubmoduleStatus status, File folder);