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

Function discoverChangedFiles

src/codeScan/git/diffProcessor.ts:144–178  ·  view source on GitHub ↗
(
  repoPath: string,
  base: string,
  compare: string,
)

Source from the content-addressed store, hash-verified

142}
143
144async function discoverChangedFiles(
145 repoPath: string,
146 base: string,
147 compare: string,
148): Promise<FileRecord[]> {
149 // Run git diff --raw and --numstat in parallel
150 const [rawResult, numstatResult] = await Promise.all([
151 execa(
152 'git',
153 ['diff', '--raw', '-z', '--no-color', '--no-ext-diff', '--no-abbrev', `${base}...${compare}`],
154 {
155 cwd: repoPath,
156 },
157 ),
158 execa('git', ['diff', '--numstat', `${base}...${compare}`], {
159 cwd: repoPath,
160 }),
161 ]);
162
163 const rawFiles = parseRawDiff(rawResult.stdout);
164 const numstatMap = parseNumstat(numstatResult.stdout);
165
166 // Merge the data
167 return rawFiles.map((file) => {
168 const stats = numstatMap.get(file.path);
169 return {
170 path: file.path,
171 status: file.status,
172 shaA: file.shaA,
173 shaB: file.shaB,
174 linesAdded: stats?.linesAdded,
175 linesRemoved: stats?.linesRemoved,
176 };
177 });
178}
179
180function filterDenylist(files: FileRecord[]): FileRecord[] {
181 return files.map((file) => {

Callers 1

processDiffFunction · 0.85

Calls 3

parseNumstatFunction · 0.85
parseRawDiffFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…