| 233 | } |
| 234 | |
| 235 | export async function isAtGitRoot(): Promise<boolean> { |
| 236 | const cwd = getCwd() |
| 237 | const gitRoot = findGitRoot(cwd) |
| 238 | if (!gitRoot) { |
| 239 | return false |
| 240 | } |
| 241 | // Resolve symlinks for accurate comparison |
| 242 | try { |
| 243 | const [resolvedCwd, resolvedGitRoot] = await Promise.all([ |
| 244 | realpath(cwd), |
| 245 | realpath(gitRoot), |
| 246 | ]) |
| 247 | return resolvedCwd === resolvedGitRoot |
| 248 | } catch { |
| 249 | return cwd === gitRoot |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | export const dirIsInGitRepo = async (cwd: string): Promise<boolean> => { |
| 254 | return findGitRoot(cwd) !== null |