Download libs/git-utils/src/branch.ts from Leon4gr45/automaker: direct link, hf CLI and curl.
- Browser
- Download file 652 Bytes
-
https://huggingface.co/spaces/Leon4gr45/automaker/resolve/main/libs/git-utils/src/branch.ts
- Command line
-
hf download hf://spaces/Leon4gr45/automaker/libs/git-utils/src/branch.ts
-
curl -L -o branch.ts https://huggingface.co/spaces/Leon4gr45/automaker/resolve/main/libs/git-utils/src/branch.ts
652 Bytes
| /** | |
| * Git branch utilities | |
| */ | |
| import { execGitCommand } from './exec.js'; | |
| /** | |
| * Get the current branch name for a given worktree path. | |
| * | |
| * @param worktreePath - Path to the git worktree | |
| * @returns Promise resolving to the current branch name (trimmed) | |
| * @throws Error if the git command fails | |
| * | |
| * @example | |
| * ```typescript | |
| * const branch = await getCurrentBranch('/path/to/worktree'); | |
| * console.log(branch); // 'main' | |
| * ``` | |
| */ | |
| export async function getCurrentBranch(worktreePath: string): Promise<string> { | |
| const branchOutput = await execGitCommand(['rev-parse', '--abbrev-ref', 'HEAD'], worktreePath); | |
| return branchOutput.trim(); | |
| } | |