()
| 27 | * @returns The current branch name or null if not found |
| 28 | */ |
| 29 | export function getGitBranch(): string | null { |
| 30 | try { |
| 31 | const result = execSync("git branch --show-current", { |
| 32 | encoding: "utf-8", |
| 33 | cwd: process.cwd(), |
| 34 | stdio: "pipe", |
| 35 | }); |
| 36 | return result.trim() || null; |
| 37 | } catch { |
| 38 | return null; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Check if current directory is a git repository |
no outgoing calls
no test coverage detected