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 / git / fetch-file-hunks / is-last-of-diff / is-last-of-diff.ts
18 lines · 616 BRaw
1import type Types from '../../types'
2
3/**
4 * Whether a row is the last file of the whole diff git printed for its
5 * fetch: the last tracked row, the untracked ones being listed apart.
6 *
7 * The built-in reads that diff in one piece and trims its end, so the last
8 * file alone has no closing empty line to draw (withClosingLine).
9 *
10 * @param data the fetch the row belongs to
11 * @param file the row
12 * @returns whether git printed this file last
13 */
14export const isLastOfDiff = (
15 data: Types.DiffData,
16 file: Types.FileStat,
17): boolean =>
18 data.files.filter(row => !row.isUntracked).at(-1)?.path === file.path