summaryrefslogtreecommitdiffstats
path: root/pkg/commands
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
parentc9de6c003bf28c7f5fdb5ed7aaf70793836b324d (diff)
allow ignoring directories
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/files.go2
-rw-r--r--pkg/commands/models/status_line_node.go26
2 files changed, 25 insertions, 3 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go
index 740928759..e7332dbbe 100644
--- a/pkg/commands/files.go
+++ b/pkg/commands/files.go
@@ -31,7 +31,7 @@ func (c *GitCommand) StageAll() error {
return c.OSCommand.RunCommand("git add -A")
}
-// UnstageAll stages all files
+// UnstageAll unstages all files
func (c *GitCommand) UnstageAll() error {
return c.OSCommand.RunCommand("git reset")
}
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
+}