diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-14 18:46:22 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-30 21:57:00 +1100 |
commit | 77a7619690ff21bc572470a1573de7f6c212d13b (patch) | |
tree | aeaed221d56eefca152dd191c9b0291cbd09812e /pkg/commands/models | |
parent | 9f2d7adb8ea8135b402cda8cbb84a97744ec7357 (diff) |
showing changes for directories
Diffstat (limited to 'pkg/commands/models')
-rw-r--r-- | pkg/commands/models/file.go | 17 | ||||
-rw-r--r-- | pkg/commands/models/status_line.go | 8 | ||||
-rw-r--r-- | pkg/commands/models/status_line_node.go | 25 |
3 files changed, 44 insertions, 6 deletions
diff --git a/pkg/commands/models/file.go b/pkg/commands/models/file.go index 4e20b7708..32e90f718 100644 --- a/pkg/commands/models/file.go +++ b/pkg/commands/models/file.go @@ -59,3 +59,20 @@ func (f *File) SubmoduleConfig(configs []*SubmoduleConfig) *SubmoduleConfig { return nil } + +func (f *File) GetHasUnstagedChanges() bool { + return f.HasUnstagedChanges +} + +func (f *File) GetHasStagedChanges() bool { + return f.HasStagedChanges +} + +func (f *File) GetIsTracked() bool { + return f.Tracked +} + +func (f *File) GetPath() string { + names := f.Names() + return names[len(names)-1] +} diff --git a/pkg/commands/models/status_line.go b/pkg/commands/models/status_line.go new file mode 100644 index 000000000..57a54573c --- /dev/null +++ b/pkg/commands/models/status_line.go @@ -0,0 +1,8 @@ +package models + +type IStatusLine interface { + GetHasUnstagedChanges() bool + GetHasStagedChanges() bool + GetIsTracked() bool + GetPath() string +} diff --git a/pkg/commands/models/status_line_node.go b/pkg/commands/models/status_line_node.go index f2031888b..92f0bba03 100644 --- a/pkg/commands/models/status_line_node.go +++ b/pkg/commands/models/status_line_node.go @@ -20,23 +20,23 @@ func (s *StatusLineNode) GetShortStatus() string { firstChar := " " secondChar := " " - if s.HasStagedChanges() { + if s.GetHasStagedChanges() { firstChar = "M" } - if s.HasUnstagedChanges() { + if s.GetHasUnstagedChanges() { secondChar = "M" } return firstChar + secondChar } -func (s *StatusLineNode) HasUnstagedChanges() bool { +func (s *StatusLineNode) GetHasUnstagedChanges() bool { if s.IsLeaf() { return s.File.HasUnstagedChanges } for _, child := range s.Children { - if child.HasUnstagedChanges() { + if child.GetHasUnstagedChanges() { return true } } @@ -44,13 +44,13 @@ func (s *StatusLineNode) HasUnstagedChanges() bool { return false } -func (s *StatusLineNode) HasStagedChanges() bool { +func (s *StatusLineNode) GetHasStagedChanges() bool { if s.IsLeaf() { return s.File.HasStagedChanges } for _, child := range s.Children { - if child.HasStagedChanges() { + if child.GetHasStagedChanges() { return true } } @@ -136,3 +136,16 @@ func (s *StatusLineNode) sortChildren() { // TODO: think about making this in-place s.Children = sortedChildren } + +func (s *StatusLineNode) GetIsTracked() bool { + if s.File != nil { + return s.File.GetIsTracked() + } + + // pretty sure I'm allowed to do this + return true +} + +func (s *StatusLineNode) GetPath() string { + return s.Path +} |