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 / tests / fixtures / git-in.ts
20 lines · 637 BRaw
1import type { ProcessRunResult } from 'claude-code'
2
3import { NOT_A_REPOSITORY } from './not-a-repository.js'
4import { REPOSITORY } from './repository.js'
5
6/**
7 * What git answers in /work (REPOSITORY); an invocation it does not know
8 * fails as git does outside a repository.
9 *
10 * @param argv the invocation, program first
11 * @returns git's exit code and output
12 */
13export function gitIn(argv: readonly string[]): ProcessRunResult {
14 const line = argv.join(' ')
15 const found = Object.entries(REPOSITORY).find(([key]) => line.includes(key))
16
17 return found
18 ? { exitCode: 0, stdout: found[1], stderr: '' }
19 : NOT_A_REPOSITORY
20}