(
dir: string,
opts?: { cwd?: string },
)
| 195 | |
| 196 | /** Get the git status of files in a directory (staged, unstaged, untracked) */ |
| 197 | export function getFileStatuses( |
| 198 | dir: string, |
| 199 | opts?: { cwd?: string }, |
| 200 | ): Map<string, 'committed' | 'staged' | 'untracked'> { |
| 201 | const statuses = new Map<string, 'committed' | 'staged' | 'untracked'>(); |
| 202 | const result = tryRunArgs(['git', 'status', '--porcelain', '--', dir], opts); |
| 203 | if (!result) return statuses; |
| 204 | for (const line of result.split('\n')) { |
| 205 | if (!line.trim()) continue; |
| 206 | const indexStatus = line[0]!; |
| 207 | const file = line.slice(3); |
| 208 | if (indexStatus === '?') { |
| 209 | statuses.set(file, 'untracked'); |
| 210 | } else { |
| 211 | statuses.set(file, 'staged'); |
| 212 | } |
| 213 | } |
| 214 | return statuses; |
| 215 | } |
| 216 | |
| 217 | /** Get all tags matching a pattern */ |
| 218 | export function listTags(pattern: string, opts?: { cwd?: string }): string[] { |
no test coverage detected
searching dependent graphs…