This commit is contained in:
Jesse Duffield
2021-03-31 22:39:55 +11:00
parent 332a3c4cbf
commit 54910fdb76
9 changed files with 76 additions and 35 deletions

View File

@@ -81,6 +81,21 @@ func (s *CommitFileChangeNode) Any(test func(node *CommitFileChangeNode) bool) b
})
}
func (s *CommitFileChangeNode) Every(test func(node *CommitFileChangeNode) bool) bool {
return every(s, func(n INode) bool {
castNode := n.(*CommitFileChangeNode)
return test(castNode)
})
}
func (s *CommitFileChangeNode) EveryFile(test func(file *models.CommitFile) bool) bool {
return every(s, func(n INode) bool {
castNode := n.(*CommitFileChangeNode)
return castNode.File == nil || test(castNode.File)
})
}
func (n *CommitFileChangeNode) Flatten(collapsedPaths map[string]bool) []*CommitFileChangeNode {
results := flatten(n, collapsedPaths)
nodes := make([]*CommitFileChangeNode, len(results))