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
33 lines · 808 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 const note = file.isUntracked
18 ? 'untracked'
19 : file.isBinary
20 ? 'Binary file'
21 : isRenamed
22 ? 'renamed'
23 : null
24
25 return {
26 key: Sections.fileKeyOf(file.path),
27 path: file.path,
28 added: file.added,
29 removed: file.removed,
30 note,
31 isSelected: file.path === selectedPath,
32 }
33}