mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-12 11:15:00 +02:00
small refactor
This commit is contained in:
parent
5bb48b51a0
commit
e52cec9cdf
@ -1,4 +1,4 @@
|
||||
package gui
|
||||
package filetree
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
)
|
||||
|
||||
func GetTreeFromFiles(files []*models.File) *models.FileChangeNode {
|
||||
func BuildTreeFromFiles(files []*models.File) *models.FileChangeNode {
|
||||
root := &models.FileChangeNode{}
|
||||
|
||||
var curr *models.FileChangeNode
|
||||
@ -49,8 +49,8 @@ func GetTreeFromFiles(files []*models.File) *models.FileChangeNode {
|
||||
return root
|
||||
}
|
||||
|
||||
func GetFlatTreeFromFiles(files []*models.File) *models.FileChangeNode {
|
||||
rootAux := GetTreeFromFiles(files)
|
||||
func BuildFlatTreeFromFiles(files []*models.File) *models.FileChangeNode {
|
||||
rootAux := BuildTreeFromFiles(files)
|
||||
sortedFiles := rootAux.GetLeaves()
|
||||
|
||||
// Move merge conflicts to top. This is the one way in which sorting
|
@ -1,4 +1,4 @@
|
||||
package gui
|
||||
package filetree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -63,9 +63,9 @@ func (m *FileChangeManager) SetFiles(files []*models.File) {
|
||||
|
||||
func (m *FileChangeManager) SetTree() {
|
||||
if m.ShowTree {
|
||||
m.Tree = GetTreeFromFiles(m.Files)
|
||||
m.Tree = BuildTreeFromFiles(m.Files)
|
||||
} else {
|
||||
m.Tree = GetFlatTreeFromFiles(m.Files)
|
||||
m.Tree = BuildFlatTreeFromFiles(m.Files)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package gui
|
||||
package filetree
|
||||
|
||||
import (
|
||||
"testing"
|
@ -21,6 +21,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||
"github.com/jesseduffield/lazygit/pkg/tasks"
|
||||
@ -303,7 +304,7 @@ type guiStateMutexes struct {
|
||||
}
|
||||
|
||||
type guiState struct {
|
||||
FileChangeManager *FileChangeManager
|
||||
FileChangeManager *filetree.FileChangeManager
|
||||
Submodules []*models.SubmoduleConfig
|
||||
Branches []*models.Branch
|
||||
Commits []*models.Commit
|
||||
@ -380,7 +381,7 @@ func (gui *Gui) resetState() {
|
||||
showTree := gui.Config.GetUserConfig().Gui.ShowFileTree
|
||||
|
||||
gui.State = &guiState{
|
||||
FileChangeManager: NewFileChangeManager(make([]*models.File, 0), gui.Log, showTree),
|
||||
FileChangeManager: filetree.NewFileChangeManager(make([]*models.File, 0), gui.Log, showTree),
|
||||
Commits: make([]*models.Commit, 0),
|
||||
FilteredReflogCommits: make([]*models.Commit, 0),
|
||||
ReflogCommits: make([]*models.Commit, 0),
|
||||
|
Loading…
Reference in New Issue
Block a user