MCPcopy
hub / github.com/jesseduffield/lazygit / commitFilePatchStatus

Function commitFilePatchStatus

pkg/gui/presentation/files.go:53–68  ·  view source on GitHub ↗

Returns the status of a commit file in terms of its inclusion in the custom patch

(node *filetree.Node[models.CommitFile], tree *filetree.CommitFileTreeViewModel, patchBuilder *patch.PatchBuilder)

Source from the content-addressed store, hash-verified

51
52// Returns the status of a commit file in terms of its inclusion in the custom patch
53func commitFilePatchStatus(node *filetree.Node[models.CommitFile], tree *filetree.CommitFileTreeViewModel, patchBuilder *patch.PatchBuilder) patch.PatchStatus {
54 // This is a little convoluted because we're dealing with either a leaf or a non-leaf.
55 // But this code actually applies to both. If it's a leaf, the status will just
56 // be whatever status it is, but if it's a non-leaf it will determine its status
57 // based on the leaves of that subtree
58 if node.EveryFile(func(file *models.CommitFile) bool {
59 return patchBuilder.GetFileStatus(file.Path, tree.GetRef().RefName()) == patch.WHOLE
60 }) {
61 return patch.WHOLE
62 } else if node.EveryFile(func(file *models.CommitFile) bool {
63 return patchBuilder.GetFileStatus(file.Path, tree.GetRef().RefName()) == patch.UNSELECTED
64 }) {
65 return patch.UNSELECTED
66 }
67 return patch.PART
68}
69
70func renderAux[T any](
71 node *filetree.Node[T],

Callers 1

RenderCommitFileTreeFunction · 0.85

Calls 4

EveryFileMethod · 0.80
GetFileStatusMethod · 0.80
RefNameMethod · 0.65
GetRefMethod · 0.65

Tested by

no test coverage detected