mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
13 lines
387 B
TypeScript
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
|
|
}
|
|
}
|