Example usage for org.eclipse.jgit.submodule SubmoduleWalk close

List of usage examples for org.eclipse.jgit.submodule SubmoduleWalk close

Introduction

In this page you can find the example usage for org.eclipse.jgit.submodule SubmoduleWalk close.

Prototype

@Override
public void close() 

Source Link

Document

Release any resources used by this walker's reader.

Usage

From source file:org.gradle.vcs.fixtures.GitFileRepository.java

License:Apache License

/**
 * Updates any submodules in this repository to the latest in the submodule origin repository
 *//*  www.jav  a  2 s  .c o  m*/
public RevCommit updateSubmodulesToLatest() throws GitAPIException {
    List<String> submodulePaths = Lists.newArrayList();
    try {
        SubmoduleWalk walker = SubmoduleWalk.forIndex(git.getRepository());
        try {
            while (walker.next()) {
                Repository submodule = walker.getRepository();
                try {
                    submodulePaths.add(walker.getPath());
                    Git.wrap(submodule).pull().call();
                } finally {
                    submodule.close();
                }
            }
        } finally {
            walker.close();
        }
        return commit("update submodules", submodulePaths.toArray(new String[submodulePaths.size()]));
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}

From source file:org.gradle.vcs.git.internal.GitVersionControlSystem.java

License:Apache License

private static void updateSubModules(Git git) throws IOException, GitAPIException {
    SubmoduleWalk walker = SubmoduleWalk.forIndex(git.getRepository());
    try {/* w  w  w  .ja  va 2 s  . c  om*/
        while (walker.next()) {
            Repository submodule = walker.getRepository();
            try {
                Git submoduleGit = Git.wrap(submodule);
                submoduleGit.fetch().call();
                git.submoduleUpdate().addPath(walker.getPath()).call();
                submoduleGit.reset().setMode(ResetCommand.ResetType.HARD).call();
                updateSubModules(submoduleGit);
            } finally {
                submodule.close();
            }
        }
    } finally {
        walker.close();
    }
}