Download mods/diff/hooks/git/cut-hunks/cut-hunks.ts from SaylorTwift/claude-code: direct link, hf CLI and curl.
- Browser
- Download file 832 Bytes
-
https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/hooks/git/cut-hunks/cut-hunks.ts
- Command line
-
hf download hf://SaylorTwift/claude-code/mods/diff/hooks/git/cut-hunks/cut-hunks.ts
-
curl -L -o cut-hunks.ts https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/hooks/git/cut-hunks/cut-hunks.ts
832 Bytes
| import Limits from '../../limits' | |
| import type Types from '../types' | |
| /** | |
| * Hunks with their lines cut at MAX_LINES_PER_FILE in all, in order, and | |
| * whether any line was dropped. | |
| * | |
| * The one bound on every body the pane draws or attaches, whether git | |
| * printed it or the transcript carried it. | |
| * | |
| * @param hunks the hunks as parsed or reported | |
| * @returns the cut hunks and whether the cut dropped lines | |
| */ | |
| export function cutHunks( | |
| hunks: readonly Types.Hunk[], | |
| ): Pick<Types.FileHunks, 'hunks' | 'isTruncated'> { | |
| let budget = Limits.MAX_LINES_PER_FILE | |
| let total = 0 | |
| return { | |
| hunks: hunks.map(hunk => { | |
| const lines = hunk.lines.slice(0, budget) | |
| budget -= lines.length | |
| total += hunk.lines.length | |
| return { ...hunk, lines } | |
| }), | |
| isTruncated: total > Limits.MAX_LINES_PER_FILE, | |
| } | |
| } | |