MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getHeadForDir

Function getHeadForDir

source code/utils/git/gitFilesystem.ts:595–608  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

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