Children will return the children of a treenoder as treenoders, building them from the children of the wrapped git tree.
()
| 68 | // Children will return the children of a treenoder as treenoders, |
| 69 | // building them from the children of the wrapped git tree. |
| 70 | func (t *treeNoder) Children() ([]noder.Noder, error) { |
| 71 | if t.mode != filemode.Dir { |
| 72 | return noder.NoChildren, nil |
| 73 | } |
| 74 | |
| 75 | // children are memoized for efficiency |
| 76 | if t.children != nil { |
| 77 | return t.children, nil |
| 78 | } |
| 79 | |
| 80 | // the parent of the returned children will be ourself as a tree if |
| 81 | // we are a not the root treenoder. The root is special as it |
| 82 | // is is own parent. |
| 83 | parent := t.parent |
| 84 | if !t.isRoot() { |
| 85 | var err error |
| 86 | if parent, err = t.parent.Tree(t.name); err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | var err error |
| 92 | t.children, err = transformChildren(parent) |
| 93 | return t.children, err |
| 94 | } |
| 95 | |
| 96 | // Returns the children of a tree as treenoders. |
| 97 | // Efficiency is key here. |
no test coverage detected