Files
orca/src/shared/git-current-branch.ts
T
OrcaWinandOrcaWin 4a0c762f24 fix(git): resolve current branches without tag ambiguity (#35040)
* fix(git): resolve current branches without tag ambiguity

* fix(git): share tag-safe current branch reader with push-target setup and trim real-git proof matrix

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-30 01:55:14 -07:00

13 lines
387 B
TypeScript

export async function getGitCurrentBranchName(
runGit: (args: string[]) => Promise<{ stdout: string }>
): Promise<string | null> {
try {
const { stdout } = await runGit(['symbolic-ref', '--quiet', 'HEAD'])
const ref = stdout.trim()
const prefix = 'refs/heads/'
return ref.startsWith(prefix) ? ref.slice(prefix.length) || null : null
} catch {
return null
}
}