summaryrefslogtreecommitdiffstats
path: root/pkg/commands/models
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-03-16 09:07:00 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-03-30 21:57:00 +1100
commitcd0532b4d6e9dcb846c6ce5ad88be7e0cf671a40 (patch)
tree3dcd1e911036ac003fd7ae222aa863a534adae6f /pkg/commands/models
parentc9de6c003bf28c7f5fdb5ed7aaf70793836b324d (diff)
allow ignoring directories
Diffstat (limited to 'pkg/commands/models')
-rw-r--r--pkg/commands/models/status_line_node.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/pkg/commands/models/status_line_node.go b/pkg/commands/models/status_line_node.go
index e0a9051e2..ce85cfec8 100644
--- a/pkg/commands/models/status_line_node.go
+++ b/pkg/commands/models/status_line_node.go
@@ -144,13 +144,19 @@ func (s *StatusLineNode) sortChildren() {
s.Children = sortedChildren
}
+// returns true if any descendant file is tracked
func (s *StatusLineNode) GetIsTracked() bool {
if s.File != nil {
return s.File.GetIsTracked()
}
- // pretty sure I'm allowed to do this
- return true
+ for _, child := range s.Children {
+ if child.GetIsTracked() {
+ return true
+ }
+ }
+
+ return false
}
func (s *StatusLineNode) GetPath() string {
@@ -211,3 +217,19 @@ func (s *StatusLineNode) ID() string {
func (s *StatusLineNode) Description() string {
return s.GetPath()
}
+
+func (s *StatusLineNode) ForEachFile(cb func(*File) error) error {
+ if s.File != nil {
+ if err := cb(s.File); err != nil {
+ return err
+ }
+ }
+
+ for _, child := range s.Children {
+ if err := child.ForEachFile(cb); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}