fix(cli): ensure branch indicator updates in sub-directories and worktrees (#26330)

This commit is contained in:
Adib234
2026-05-04 13:35:13 -04:00
committed by GitHub
parent 9de8c8aadb
commit 704be5a418
3 changed files with 169 additions and 74 deletions
+12
View File
@@ -6,6 +6,18 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { spawnAsync } from './shell-utils.js';
/**
* Gets the absolute path to the git directory (.git) for the given working directory.
* This handles standard git repositories, subdirectories, and worktrees.
*/
export async function getAbsoluteGitDir(cwd: string): Promise<string> {
const result = await spawnAsync('git', ['rev-parse', '--absolute-git-dir'], {
cwd,
});
return result.stdout.trim();
}
/**
* Checks if a directory is within a git repository