MCPcopy Create free account
hub / github.com/promptfoo/promptfoo / collectBlobSizes

Function collectBlobSizes

src/codeScan/git/diffProcessor.ts:189–242  ·  view source on GitHub ↗
(
  repoPath: string,
  files: FileRecord[],
)

Source from the content-addressed store, hash-verified

187}
188
189async 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
244function attachBlobSizesAndFilter(files: FileRecord[], sizeMap: Map<string, number>): FileRecord[] {
245 return files.map((file) => {

Callers 1

processDiffFunction · 0.85

Calls 3

splitMethod · 0.80
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…