( repoPath: string, files: FileRecord[], )
| 187 | } |
| 188 | |
| 189 | async function collectBlobSizes( |
| 190 | repoPath: string, |
| 191 | files: FileRecord[], |
| 192 | ): Promise<Map<string, number>> { |
| 193 | const shas = new Set<string>(); |
| 194 | |
| 195 | for (const file of files) { |
| 196 | if (file.skipReason) { |
| 197 | continue; // Skip files already marked for skipping |
| 198 | } |
| 199 | |
| 200 | if (file.shaA) { |
| 201 | shas.add(file.shaA); |
| 202 | } |
| 203 | if (file.shaB) { |
| 204 | shas.add(file.shaB); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (shas.size === 0) { |
| 209 | return new Map(); |
| 210 | } |
| 211 | |
| 212 | // Use git cat-file --batch-check |
| 213 | const shaList = Array.from(shas).join('\n'); |
| 214 | const result = await execa( |
| 215 | 'git', |
| 216 | ['cat-file', '--batch-check=%(objectname) %(objecttype) %(objectsize)'], |
| 217 | { |
| 218 | cwd: repoPath, |
| 219 | input: shaList, |
| 220 | }, |
| 221 | ); |
| 222 | |
| 223 | const sizeMap = new Map<string, number>(); |
| 224 | |
| 225 | for (const line of result.stdout.split('\n')) { |
| 226 | if (!line.trim()) { |
| 227 | continue; |
| 228 | } |
| 229 | |
| 230 | const parts = line.split(/\s+/); |
| 231 | if (parts.length < 3) { |
| 232 | continue; |
| 233 | } |
| 234 | |
| 235 | const sha = parts[0]; |
| 236 | const size = Number.parseInt(parts[2], 10); |
| 237 | |
| 238 | sizeMap.set(sha, size); |
| 239 | } |
| 240 | |
| 241 | return sizeMap; |
| 242 | } |
| 243 | |
| 244 | function attachBlobSizesAndFilter(files: FileRecord[], sizeMap: Map<string, number>): FileRecord[] { |
| 245 | return files.map((file) => { |
no test coverage detected
searching dependent graphs…