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 / tiers / with-untracked / with-untracked.ts
34 lines · 1.1 KBRaw
1import Limits from '../../../limits'
2import Probes from '../../probes'
3import type Types from '../../types'
4import { isPastDetails } from '../is-past-details'
5import { mergedResultOf } from './merged-result-of'
6import { mergedWithUntracked } from './merged-with-untracked'
7
8/**
9 * A tier's rows with the untracked files merged after them
10 * (mergedWithUntracked).
11 *
12 * Past MAX_FILES_FOR_DETAILS nothing is listed; a listing git withheld
13 * leaves the tracked rows as they are and says so, as the built-in degrades.
14 *
15 * @param context the fetch
16 * @param result the tier's tracked rows and totals
17 * @param scope which untracked files count
18 * @returns the merged rows and totals, and whether the listing was withheld
19 */
20export async function withUntracked(
21 context: Types.FetchContext,
22 result: Types.NumstatResult,
23 scope: Types.UntrackedScope,
24): Promise<Types.MergedResult> {
25 return isPastDetails(result)
26 ? mergedResultOf(result, { isUntrackedWithheld: false })
27 : mergedWithUntracked(
28 result,
29 await Probes.untrackedFiles(context, {
30 slots: Limits.MAX_FILES - result.files.length,
31 scope,
32 }),
33 )
34}