summaryrefslogtreecommitdiffstats
path: root/pkg/commands/models
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-03-15 22:29:34 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-03-30 21:57:00 +1100
commit418621a9ff41f1282e471ce2250f62c9e1d2bdbf (patch)
tree4c33302c7be48c795aa144b9565471e192fc38ba /pkg/commands/models
parentf871724ae63753c34942efea47a360cc64283515 (diff)
support discarding changes in dir
Diffstat (limited to 'pkg/commands/models')
-rw-r--r--pkg/commands/models/status_line_node.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/commands/models/status_line_node.go b/pkg/commands/models/status_line_node.go
index 3ed1a573a..1a2471935 100644
--- a/pkg/commands/models/status_line_node.go
+++ b/pkg/commands/models/status_line_node.go
@@ -188,3 +188,18 @@ func (s *StatusLineNode) compressAux() *StatusLineNode {
func (s *StatusLineNode) HasExactlyOneChild() bool {
return len(s.Children) == 1
}
+
+// This ignores the root
+func (s *StatusLineNode) GetPathsMatching(test func(*StatusLineNode) bool) []string {
+ paths := []string{}
+
+ if test(s) {
+ paths = append(paths, s.GetPath())
+ }
+
+ for _, child := range s.Children {
+ paths = append(paths, child.GetPathsMatching(test)...)
+ }
+
+ return paths
+}