(cwd: string)
| 55 | } |
| 56 | |
| 57 | export async function getGitStatus(cwd: string): Promise<GitStatusResponse> { |
| 58 | const repositoryRoot = await findRepositoryRoot(cwd); |
| 59 | if (!repositoryRoot) { |
| 60 | return { isGitRepository: false, repositoryRoot: null, files: [] }; |
| 61 | } |
| 62 | |
| 63 | const entries = await readStatusEntries(repositoryRoot); |
| 64 | const files = entries.flatMap((entry): GitFileStatus[] => { |
| 65 | const filePath = path.resolve(repositoryRoot, entry.path); |
| 66 | if (!isWithinPath(cwd, filePath)) return []; |
| 67 | const classified = classifyGitStatus(entry); |
| 68 | return [{ |
| 69 | filePath, |
| 70 | ...classified, |
| 71 | indexStatus: entry.indexStatus, |
| 72 | worktreeStatus: entry.worktreeStatus, |
| 73 | }]; |
| 74 | }); |
| 75 | |
| 76 | return { isGitRepository: true, repositoryRoot, files }; |
| 77 | } |
| 78 | |
| 79 | function hasNullByte(content: Buffer): boolean { |
| 80 | return content.includes(0); |
no test coverage detected