mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-18 05:17:55 +02:00
1dd7307fde
more and more move rebase commit refreshing into existing abstraction and more and more WIP and more handling clicks properly fix merge conflicts update cheatsheet lots more preparation to start moving things into controllers WIP better typing expand on remotes controller moving more code into controllers
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package gui
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
|
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
|
)
|
|
|
|
type WorkingTreeHelper struct {
|
|
fileTreeViewModel *filetree.FileTreeViewModel
|
|
}
|
|
|
|
func NewWorkingTreeHelper(fileTreeViewModel *filetree.FileTreeViewModel) *WorkingTreeHelper {
|
|
return &WorkingTreeHelper{
|
|
fileTreeViewModel: fileTreeViewModel,
|
|
}
|
|
}
|
|
|
|
func (self *WorkingTreeHelper) AnyStagedFiles() bool {
|
|
files := self.fileTreeViewModel.GetAllFiles()
|
|
for _, file := range files {
|
|
if file.HasStagedChanges {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (self *WorkingTreeHelper) AnyTrackedFiles() bool {
|
|
files := self.fileTreeViewModel.GetAllFiles()
|
|
for _, file := range files {
|
|
if file.Tracked {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (self *WorkingTreeHelper) IsWorkingTreeDirty() bool {
|
|
return self.AnyStagedFiles() || self.AnyTrackedFiles()
|
|
}
|
|
|
|
func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File {
|
|
for _, file := range self.fileTreeViewModel.GetAllFiles() {
|
|
if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) {
|
|
return file
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|