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 / stamp-if-file / stamp-if-file.ts
29 lines · 970 BRaw
1import type Types from '../../types'
2
3/**
4 * A path's modification time when the walk shows it as a real entry of the
5 * wanted kind under real directories; otherwise nothing is stat'ed.
6 *
7 * A path git printed with a trailing `/` (an untracked directory, a nested
8 * repository) names a directory and is dated as one.
9 *
10 * @param probe the walk over the base directory and the timestamp probe
11 * @param path the path relative to the walk's root
12 * @returns the timestamp, `over-budget`, or null
13 */
14export async function stampIfFile(
15 probe: Types.StampProbe,
16 path: string,
17): Promise<Types.Stamp> {
18 const isDirectory = path.endsWith('/')
19 const entry = isDirectory ? path.slice(0, -1) : path
20 const kind = await probe.walk.kindOf(entry)
21 const isUnlisted = kind === 'over-budget'
22 const isWanted = kind === (isDirectory ? 'dir' : 'file')
23
24 return isUnlisted
25 ? 'over-budget'
26 : isWanted
27 ? probe.mtimeOf(`${probe.base}/${entry}`)
28 : null
29}