I need to clone an existing git repository into an InMemoryRepository, using JGit, change a file\'s content and push the changes back to the remote repository.<
Also, with a small tweak on previous answer:
Filtering files by extension
public Function> lastCommitFiles = (extension) -> {
final List paths = new ArrayList<>();
try {
...
try (TreeWalk walk = new TreeWalk(inMemoryRepository)) {
walk.addTree(revTree);
walk.setRecursive(true);
walk.setPostOrderTraversal(true);
while (walk.next()) {
if ((extension != null && extension.length() > 0)) {
if (walk.getPathString().lastIndexOf(extension) != -1) {
paths.add(walk.getPathString());
}
} else paths.add(walk.getPathString());
}
}
return paths;
} catch (GitAPIException | IOException e) {
log.error(e.getMessage());
}
return paths;
};