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 / probes / is-transient.ts
22 lines · 761 BRaw
1import type Types from '../types'
2import { TRANSIENT_STATE_FILES } from './transient-state-files'
3
4/**
5 * Whether the repository is mid-merge, mid-rebase, mid-cherry-pick or
6 * mid-revert, from one listing of the git directory.
7 *
8 * A state file counts only as a real file; a symbolic link by that name is
9 * never touched.
10 *
11 * @param entryKindsOf the host's directory listing
12 * @param gitDir the repository's own git directory, absolute
13 * @returns whether any of TRANSIENT_STATE_FILES is present as a file
14 */
15export async function isTransient(
16 entryKindsOf: Types.GitDeps['entryKindsOf'],
17 gitDir: string,
18): Promise<boolean> {
19 const entries = await entryKindsOf(gitDir)
20
21 return TRANSIENT_STATE_FILES.some(file => entries?.get(file) === 'file')
22}