fix: Resolve git operation error handling and conflict detection issues

This commit is contained in:
gsxdsm
2026-02-18 23:03:39 -08:00
parent 205f662022
commit a144a63c51
8 changed files with 50 additions and 17 deletions

View File

@@ -0,0 +1,23 @@
/**
* 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();
}

View File

@@ -23,3 +23,6 @@ export {
// Export conflict utilities
export { getConflictFiles } from './conflict.js';
// Export branch utilities
export { getCurrentBranch } from './branch.js';