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

Function getCommitFileLine

pkg/gui/presentation/files.go:220–283  ·  view source on GitHub ↗
(
	isCollapsed bool,
	treeDepth int,
	visualDepth int,
	node *filetree.Node[models.CommitFile],
	status patch.PatchStatus,
	showFileIcons bool,
	customIconsConfig *config.CustomIconsConfig,
)

Source from the content-addressed store, hash-verified

218}
219
220func getCommitFileLine(
221 isCollapsed bool,
222 treeDepth int,
223 visualDepth int,
224 node *filetree.Node[models.CommitFile],
225 status patch.PatchStatus,
226 showFileIcons bool,
227 customIconsConfig *config.CustomIconsConfig,
228) string {
229 indentation := strings.Repeat(" ", visualDepth)
230 name := commitFileNameAtDepth(node, treeDepth)
231 commitFile := node.File
232 output := indentation
233
234 isDirectory := commitFile == nil
235
236 nameColor := theme.DefaultTextColor
237
238 switch status {
239 case patch.WHOLE:
240 nameColor = style.FgGreen
241 case patch.PART:
242 nameColor = style.FgYellow
243 case patch.UNSELECTED:
244 nameColor = theme.DefaultTextColor
245 }
246
247 if isDirectory {
248 arrow := EXPANDED_ARROW
249 if isCollapsed {
250 arrow = COLLAPSED_ARROW
251 }
252
253 output += nameColor.Sprint(arrow) + " "
254 } else {
255 var symbol string
256 symbolStyle := nameColor
257
258 switch status {
259 case patch.WHOLE:
260 symbol = "●"
261 case patch.PART:
262 symbol = "◐"
263 case patch.UNSELECTED:
264 symbol = commitFile.ChangeStatus
265 symbolStyle = getColorForChangeStatus(symbol)
266 }
267
268 output += symbolStyle.Sprint(symbol) + " "
269 }
270
271 name = utils.EscapeSpecialChars(name)
272 isSubmodule := false
273 isLinkedWorktree := false
274
275 if showFileIcons {
276 icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory, customIconsConfig)
277 paint := color.HEX(icon.Color, false)

Callers 1

RenderCommitFileTreeFunction · 0.85

Calls 5

EscapeSpecialCharsFunction · 0.92
IconForFileFunction · 0.92
commitFileNameAtDepthFunction · 0.85
getColorForChangeStatusFunction · 0.85
SprintMethod · 0.65

Tested by

no test coverage detected