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)
| 51 | |
| 52 | // Returns the status of a commit file in terms of its inclusion in the custom patch |
| 53 | func 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 | |
| 70 | func renderAux[T any]( |
| 71 | node *filetree.Node[T], |
no test coverage detected