()
| 371 | * @returns The current branch name |
| 372 | */ |
| 373 | export async function getCurrentBranch(): Promise<string> { |
| 374 | const cmd = new Deno.Command("git", { |
| 375 | args: ["rev-parse", "--abbrev-ref", "HEAD"], |
| 376 | stdout: "piped", |
| 377 | stderr: "piped", |
| 378 | }); |
| 379 | |
| 380 | const output = await cmd.output(); |
| 381 | if (!output.success) { |
| 382 | const errorOutput = new TextDecoder().decode(output.stderr); |
| 383 | await logMessage("error", `Getting current branch failed: ${errorOutput}`); |
| 384 | throw new Error(`Getting current branch failed: ${errorOutput}`); |
| 385 | } |
| 386 | |
| 387 | const branch = new TextDecoder().decode(output.stdout).trim(); |
| 388 | |
| 389 | return branch; |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Check if the repository is clean (no uncommitted changes) |
no test coverage detected