@@ -36,7 +36,6 @@ import type {
36
36
GitRefs ,
37
37
Logger ,
38
38
Options ,
39
- OutputFiles ,
40
39
ProjectRunResult ,
41
40
ProviderAPIClient ,
42
41
Settings ,
@@ -201,14 +200,19 @@ export async function compareReports(
201
200
args : CompareReportsArgs ,
202
201
) : Promise < ProjectRunResult > {
203
202
const { ctx, env, config } = args ;
204
- const { logger } = env . settings ;
203
+ const { settings } = env ;
204
+ const { logger } = settings ;
205
205
206
206
await prepareReportFilesToCompare ( args ) ;
207
207
await runCompare ( ctx , { hasFormats : hasDefaultPersistFormats ( config ) } ) ;
208
208
209
209
logger . info ( 'Compared reports and generated diff files' ) ;
210
210
211
- return saveDiffFiles ( args ) ;
211
+ const newIssues = settings . detectNewIssues
212
+ ? await findNewIssues ( args )
213
+ : undefined ;
214
+
215
+ return saveDiffFiles ( args , newIssues ) ;
212
216
}
213
217
214
218
export async function prepareReportFilesToCompare (
@@ -264,7 +268,10 @@ export async function prepareReportFilesToCompare(
264
268
) ;
265
269
}
266
270
267
- export async function saveDiffFiles ( args : CompareReportsArgs ) {
271
+ export async function saveDiffFiles (
272
+ args : CompareReportsArgs ,
273
+ newIssues : SourceFileIssue [ ] | undefined ,
274
+ ) {
268
275
const {
269
276
project,
270
277
ctx,
@@ -291,10 +298,8 @@ export async function saveDiffFiles(args: CompareReportsArgs) {
291
298
settings,
292
299
} ) ,
293
300
} ,
294
- ...( settings . detectNewIssues && {
295
- newIssues : await findNewIssues ( { ...args , diffFiles } ) ,
296
- } ) ,
297
- } ;
301
+ ...( newIssues && { newIssues } ) ,
302
+ } satisfies ProjectRunResult ;
298
303
}
299
304
300
305
export async function saveReportFiles < T extends 'current' | 'previous' > ( args : {
@@ -536,25 +541,32 @@ export function configFromPatterns(
536
541
}
537
542
538
543
export async function findNewIssues (
539
- args : CompareReportsArgs & { diffFiles : OutputFiles } ,
544
+ args : CompareReportsArgs ,
540
545
) : Promise < SourceFileIssue [ ] > {
541
546
const {
542
547
base,
543
548
currReport,
544
549
prevReport,
545
- diffFiles,
550
+ config,
551
+ ctx,
546
552
env : {
547
553
git,
548
554
settings : { logger } ,
549
555
} ,
550
556
} = args ;
551
557
558
+ const diffFiles = persistedFilesFromConfig ( config , {
559
+ directory : ctx . directory ,
560
+ isDiff : true ,
561
+ } ) ;
562
+
552
563
await git . fetch ( 'origin' , base . ref , [ '--depth=1' ] ) ;
553
564
const reportsDiff = await readFile ( diffFiles . json , 'utf8' ) ;
554
565
const changedFiles = await listChangedFiles (
555
566
{ base : 'FETCH_HEAD' , head : 'HEAD' } ,
556
567
git ,
557
568
) ;
569
+
558
570
const issues = filterRelevantIssues ( {
559
571
currReport : JSON . parse ( currReport . content ) as Report ,
560
572
prevReport : JSON . parse ( prevReport . content ) as Report ,
0 commit comments