blob: 3b0162d7513d612058eeee3ced6a46480200b672 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package gui
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
type WorkingTreeHelper struct {
getFiles func() []*models.File
}
func NewWorkingTreeHelper(getFiles func() []*models.File) *WorkingTreeHelper {
return &WorkingTreeHelper{
getFiles: getFiles,
}
}
func (self *WorkingTreeHelper) AnyStagedFiles() bool {
files := self.getFiles()
for _, file := range files {
if file.HasStagedChanges {
return true
}
}
return false
}
func (self *WorkingTreeHelper) AnyTrackedFiles() bool {
files := self.getFiles()
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.getFiles() {
if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) {
return file
}
}
return nil
}
|