(cwd: string)
| 591 | * Used by plugins that need the HEAD of a specific repo, not the CWD repo. |
| 592 | */ |
| 593 | export 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). |
no test coverage detected