MCPcopy
hub / github.com/claude-code-best/claude-code / getHeadForDir

Function getHeadForDir

src/utils/git/gitFilesystem.ts:593–606  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

591 * Used by plugins that need the HEAD of a specific repo, not the CWD repo.
592 */
593export async function getHeadForDir(cwd: string): Promise<string | null> {
594 const gitDir = await resolveGitDir(cwd)
595 if (!gitDir) {
596 return null
597 }
598 const head = await readGitHead(gitDir)
599 if (!head) {
600 return null
601 }
602 if (head.type === 'branch') {
603 return resolveRef(gitDir, `refs/heads/${head.name}`)
604 }
605 return head.sha
606}
607
608/**
609 * Read the HEAD SHA for a git worktree directory (not the main repo).

Callers 2

getGitCommitShaFunction · 0.85
getGitCommitShaFunction · 0.85

Calls 3

resolveGitDirFunction · 0.85
readGitHeadFunction · 0.85
resolveRefFunction · 0.85

Tested by

no test coverage detected