1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/filetree/file_node.go

56 lines
1.3 KiB
Go
Raw Normal View History

2021-03-21 06:58:15 +02:00
package filetree
import "github.com/jesseduffield/lazygit/pkg/commands/models"
// FileNode wraps a node and provides some file-specific methods for it.
type FileNode struct {
*Node[models.File]
}
var _ models.IFile = &FileNode{}
func NewFileNode(node *Node[models.File]) *FileNode {
if node == nil {
return nil
}
return &FileNode{Node: node}
}
// returns the underlying node, without any file-specific methods attached
func (self *FileNode) Raw() *Node[models.File] {
2022-08-01 12:32:01 +02:00
if self == nil {
return nil
}
return self.Node
}
2021-03-14 09:46:22 +02:00
func (self *FileNode) GetHasUnstagedChanges() bool {
return self.SomeFile(func(file *models.File) bool { return file.HasUnstagedChanges })
2021-03-14 09:46:22 +02:00
}
func (self *FileNode) GetHasStagedChanges() bool {
return self.SomeFile(func(file *models.File) bool { return file.HasStagedChanges })
}
func (self *FileNode) GetHasInlineMergeConflicts() bool {
return self.SomeFile(func(file *models.File) bool { return file.HasInlineMergeConflicts })
2021-03-30 14:56:59 +02:00
}
func (self *FileNode) GetIsTracked() bool {
return self.SomeFile(func(file *models.File) bool { return file.Tracked })
}
2021-03-15 13:29:34 +02:00
2022-11-11 03:16:38 +02:00
func (self *FileNode) GetIsFile() bool {
return self.IsFile()
}
func (self *FileNode) GetPreviousPath() string {
if self.File == nil {
return ""
2021-03-21 01:46:43 +02:00
}
return self.File.PreviousName
2021-03-21 01:46:43 +02:00
}