1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

remove collapsed field

This commit is contained in:
Jesse Duffield 2021-03-21 15:01:13 +11:00
parent f742434043
commit ef204b0adf
3 changed files with 14 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package models
// sometimes we need to deal with either a node (which contains a file) or an actual file
type IFileChange interface {
GetHasUnstagedChanges() bool
GetHasStagedChanges() bool

View File

@ -12,8 +12,7 @@ type FileChangeNode struct {
Children []*FileChangeNode
File *File
Path string // e.g. '/path/to/mydir'
Collapsed bool
CompressionLevel int // equal to the number of forward slashes you'll see in the path when it's rendered in tree mode
CompressionLevel int // equal to the number of forward slashes you'll see in the path when it's rendered in tree mode
}
func (s *FileChangeNode) GetHasUnstagedChanges() bool {

View File

@ -9,9 +9,10 @@ import (
func TestRender(t *testing.T) {
scenarios := []struct {
name string
root *models.FileChangeNode
expected []string
name string
root *models.FileChangeNode
collapsedPaths map[string]bool
expected []string
}{
{
name: "nil node",
@ -34,13 +35,16 @@ func TestRender(t *testing.T) {
Path: "",
Children: []*models.FileChangeNode{
{
Path: "dir1",
Collapsed: true,
Path: "dir1",
Children: []*models.FileChangeNode{
{
File: &models.File{Name: "dir1/file2", ShortStatus: "M ", HasUnstagedChanges: true},
Path: "dir1/file2",
},
{
File: &models.File{Name: "dir1/file3", ShortStatus: "M ", HasUnstagedChanges: true},
Path: "dir1/file3",
},
},
},
{
@ -71,15 +75,15 @@ func TestRender(t *testing.T) {
},
},
},
expected: []string{"dir1 ▼", "└─ M file2", "dir2 ▼", "├─ dir2 ▼", "│ ├─ M file3", "│ └─ M file4", "└─ M file5", "M file1"},
expected: []string{"dir1 ►", "dir2 ▼", "├─ dir2 ▼", "│ ├─ M file3", "│ └─ M file4", "└─ M file5", "M file1"},
collapsedPaths: map[string]bool{"dir1": true},
},
}
for _, s := range scenarios {
s := s
t.Run(s.name, func(t *testing.T) {
mngr := &FileChangeManager{Tree: s.root}
mngr := &FileChangeManager{Tree: s.root, CollapsedPaths: s.collapsedPaths}
result := mngr.Render("", nil)
assert.EqualValues(t, s.expected, result)
})