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