Tree traversal from commit & its associated tests

This commit is contained in:
Kohsuke Kawaguchi
2016-12-17 07:21:31 -08:00
parent b5386a35ee
commit a454fb10ec
3 changed files with 32 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import java.util.List;
* https://developer.github.com/v3/git/trees/
*
* @author Daniel Teixeira - https://github.com/ddtxra
* @see GHCommit#getTree()
* @see GHRepository#getTree(String)
* @see GHTreeEntry#asTree()
*/
@@ -35,6 +36,19 @@ public class GHTree {
return Collections.unmodifiableList(Arrays.asList(tree));
}
/**
* Finds a tree entry by its name.
*
* IOW, find a directory entry by a file name.
*/
public GHTreeEntry getEntry(String path) {
for (GHTreeEntry e : tree) {
if (e.getPath().equals(path))
return e;
}
return null;
}
/**
* Returns true if the number of items in the tree array exceeded the GitHub maximum limit.
* @return true true if the number of items in the tree array exceeded the GitHub maximum limit otherwise false.