diff options
Diffstat (limited to 'src/main/git.ts')
| -rw-r--r-- | src/main/git.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/git.ts b/src/main/git.ts index 20362a7..ec81e8f 100644 --- a/src/main/git.ts +++ b/src/main/git.ts | |||
| @@ -58,6 +58,29 @@ export function ensureGitRepo(projectPath: string): void { | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | // --------------------------------------------------------------------------- | 60 | // --------------------------------------------------------------------------- |
| 61 | // Current branch query | ||
| 62 | // --------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Returns the name of the currently checked-out branch, | ||
| 66 | * or null if git is unavailable or HEAD is detached. | ||
| 67 | */ | ||
| 68 | export function getCurrentBranch(projectPath: string): string | null { | ||
| 69 | try { | ||
| 70 | return ( | ||
| 71 | execFileSync("git", ["branch", "--show-current"], { | ||
| 72 | cwd: projectPath, | ||
| 73 | stdio: "pipe", | ||
| 74 | }) | ||
| 75 | .toString() | ||
| 76 | .trim() || null | ||
| 77 | ); | ||
| 78 | } catch { | ||
| 79 | return null; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | // --------------------------------------------------------------------------- | ||
| 61 | // Branch creation | 84 | // Branch creation |
| 62 | // --------------------------------------------------------------------------- | 85 | // --------------------------------------------------------------------------- |
| 63 | 86 | ||
