Download mods/diff/tests/fixtures/git-word-of.ts from SaylorTwift/claude-code: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/tests/fixtures/git-word-of.ts
- Command line
-
hf download hf://SaylorTwift/claude-code/mods/diff/tests/fixtures/git-word-of.ts
-
curl -L -o git-word-of.ts https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/tests/fixtures/git-word-of.ts
1.15 kB
| /** | |
| * One git invocation named by what it asks: its subcommand, and its kind. | |
| * | |
| * For a `diff` what kind (`--shortstat`, `--numstat`, or the path its body | |
| * is asked for), for a `rev-parse` whether it finds the repository | |
| * (`--show-toplevel`) or reads `HEAD` (the poll's fallback where no file | |
| * answers), so a test reads a session's spawns as the built-in's list. | |
| * | |
| * @param argv the invocation, program first, any pinned lead after it | |
| * @returns `rev-parse --show-toplevel`, `status`, `diff --numstat`, ... | |
| */ | |
| export function gitWordOf(argv: readonly string[]) { | |
| const [subcommand = '?'] = argv.filter( | |
| (word, at) => at > 0 && !word.startsWith('-') && argv[at - 1] !== '-c', | |
| ) | |
| const dashes = argv.indexOf('--') | |
| if (subcommand === 'rev-parse') { | |
| return argv.includes('--show-toplevel') | |
| ? 'rev-parse --show-toplevel' | |
| : 'rev-parse HEAD' | |
| } | |
| if (subcommand !== 'diff') { | |
| return subcommand | |
| } | |
| if (dashes !== -1) { | |
| return `diff -- ${argv.slice(dashes + 1).join(' ')}` | |
| } | |
| const stat = argv.find(word => word === '--shortstat' || word === '--numstat') | |
| return stat ? `diff ${stat}` : 'diff' | |
| } | |