use of org.eclipse.jgit.treewalk.TreeWalk in project gitiles by GerritCodeReview.
the class ReadmeHelper method scanTree.
void scanTree(RevTree tree) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException {
if (config.render) {
try (TreeWalk tw = new TreeWalk(reader)) {
tw.setRecursive(false);
tw.addTree(tree);
while (tw.next() && !isPresent()) {
considerEntry(tw);
}
}
}
}
use of org.eclipse.jgit.treewalk.TreeWalk in project gerrit by GerritCodeReview.
the class CreateProjectIT method assertEmptyCommit.
private void assertEmptyCommit(String projectName, String... refs) throws Exception {
Project.NameKey projectKey = new Project.NameKey(projectName);
try (Repository repo = repoManager.openRepository(projectKey);
RevWalk rw = new RevWalk(repo);
TreeWalk tw = new TreeWalk(rw.getObjectReader())) {
for (String ref : refs) {
RevCommit commit = rw.lookupCommit(repo.exactRef(ref).getObjectId());
rw.parseBody(commit);
tw.addTree(commit.getTree());
assertThat(tw.next()).isFalse();
tw.reset();
}
}
}
use of org.eclipse.jgit.treewalk.TreeWalk in project gerrit by GerritCodeReview.
the class VersionedMetaData method getPathInfos.
public List<PathInfo> getPathInfos(boolean recursive) throws IOException {
try (TreeWalk tw = new TreeWalk(reader)) {
tw.addTree(revision.getTree());
tw.setRecursive(recursive);
List<PathInfo> paths = new ArrayList<>();
while (tw.next()) {
paths.add(new PathInfo(tw));
}
return paths;
}
}
use of org.eclipse.jgit.treewalk.TreeWalk in project gerrit by GerritCodeReview.
the class ListDashboards method scanDashboards.
private List<DashboardInfo> scanDashboards(Project definingProject, Repository git, RevWalk rw, Ref ref, String project, boolean setDefault) throws IOException {
List<DashboardInfo> list = new ArrayList<>();
try (TreeWalk tw = new TreeWalk(rw.getObjectReader())) {
tw.addTree(rw.parseTree(ref.getObjectId()));
tw.setRecursive(true);
while (tw.next()) {
if (tw.getFileMode(0) == FileMode.REGULAR_FILE) {
try {
list.add(DashboardsCollection.parse(definingProject, ref.getName().substring(REFS_DASHBOARDS.length()), tw.getPathString(), new BlobBasedConfig(null, git, tw.getObjectId(0)), project, setDefault));
} catch (ConfigInvalidException e) {
log.warn(String.format("Cannot parse dashboard %s:%s:%s: %s", definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage()));
}
}
}
}
return list;
}
use of org.eclipse.jgit.treewalk.TreeWalk in project gitiles by GerritCodeReview.
the class ArchiveServlet method getTree.
private ObjectId getTree(GitilesView view, Repository repo, Revision rev) throws IOException {
try (RevWalk rw = new RevWalk(repo)) {
RevTree tree = rw.parseTree(rev.getId());
if (Strings.isNullOrEmpty(view.getPathPart())) {
return tree;
}
TreeWalk tw = TreeWalk.forPath(rw.getObjectReader(), view.getPathPart(), tree);
if (tw == null || tw.getFileMode(0) != FileMode.TREE) {
return ObjectId.zeroId();
}
return tw.getObjectId(0);
} catch (IncorrectObjectTypeException e) {
return ObjectId.zeroId();
}
}
Aggregations