( stdout: string, filter: Set<string> | undefined, )
| 37 | export const IFsGitService = createDecorator<IFsGitService>('fsGitService'); |
| 38 | |
| 39 | export function parsePorcelain( |
| 40 | stdout: string, |
| 41 | filter: Set<string> | undefined, |
| 42 | ): FsGitStatusResponse { |
| 43 | const lines = stdout.split('\n'); |
| 44 | let branch = ''; |
| 45 | let ahead = 0; |
| 46 | let behind = 0; |
| 47 | const entries: Record<string, FsGitStatus> = {}; |
| 48 | |
| 49 | for (const line of lines) { |
| 50 | if (line.length === 0) continue; |
| 51 | if (line.startsWith('## ')) { |
| 52 | const parsed = parseBranchHeader(line.slice(3)); |
| 53 | branch = parsed.branch; |
| 54 | ahead = parsed.ahead; |
| 55 | behind = parsed.behind; |
| 56 | continue; |
| 57 | } |
| 58 | |
| 59 | if (line.length < 4) continue; |
| 60 | const xy = line.slice(0, 2); |
| 61 | let rest = line.slice(3); |
| 62 | |
| 63 | if (xy.startsWith('R') || xy.startsWith('C')) { |
| 64 | const arrow = rest.indexOf(' -> '); |
| 65 | if (arrow >= 0) { |
| 66 | rest = rest.slice(arrow + 4); |
| 67 | } |
| 68 | } |
| 69 | const wirePath = posix(rest.trim()); |
| 70 | if (filter !== undefined && !filter.has(wirePath)) continue; |
| 71 | const status = collapseXY(xy); |
| 72 | entries[wirePath] = status; |
| 73 | } |
| 74 | |
| 75 | return { branch, ahead, behind, entries, additions: 0, deletions: 0, pullRequest: null }; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Sum added/deleted line counts from `git diff --numstat` output. Each line is |
no test coverage detected