spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / views / current-pane / file-row-of / file-row-of.ts
34 lines · 809 BRaw
1import type Git from '../../../git'
2import Sections from '../../sections'
3
4/**
5 * A fetched row as the list draws it: its counts, or a note in their
6 * place (`untracked`, `Binary file`, `renamed`), and selection.
7 *
8 * @param file the row
9 * @param selectedPath the selected file's path, or null
10 * @returns the row model
11 */
12export function fileRowOf(
13 file: Git.FileStat,
14 selectedPath: string | null,
15): Sections.FileRowModel {
16 const isRenamed = file.renamedFrom !== null
17
18 const note = file.isUntracked
19 ? 'untracked'
20 : file.isBinary
21 ? 'Binary file'
22 : isRenamed
23 ? 'renamed'
24 : null
25
26 return {
27 key: Sections.fileKeyOf(file.path),
28 path: file.path,
29 added: file.added,
30 removed: file.removed,
31 note,
32 isSelected: file.path === selectedPath,
33 }
34}