@@ -36,7 +36,6 @@ import type {
3636 GitRefs ,
3737 Logger ,
3838 Options ,
39- OutputFiles ,
4039 ProjectRunResult ,
4140 ProviderAPIClient ,
4241 Settings ,
@@ -201,14 +200,19 @@ export async function compareReports(
201200 args : CompareReportsArgs ,
202201) : Promise < ProjectRunResult > {
203202 const { ctx, env, config } = args ;
204- const { logger } = env . settings ;
203+ const { settings } = env ;
204+ const { logger } = settings ;
205205
206206 await prepareReportFilesToCompare ( args ) ;
207207 await runCompare ( ctx , { hasFormats : hasDefaultPersistFormats ( config ) } ) ;
208208
209209 logger . info ( 'Compared reports and generated diff files' ) ;
210210
211- return saveDiffFiles ( args ) ;
211+ const newIssues = settings . detectNewIssues
212+ ? await findNewIssues ( args )
213+ : undefined ;
214+
215+ return saveDiffFiles ( args , newIssues ) ;
212216}
213217
214218export async function prepareReportFilesToCompare (
@@ -264,7 +268,10 @@ export async function prepareReportFilesToCompare(
264268 ) ;
265269}
266270
267- export async function saveDiffFiles ( args : CompareReportsArgs ) {
271+ export async function saveDiffFiles (
272+ args : CompareReportsArgs ,
273+ newIssues : SourceFileIssue [ ] | undefined ,
274+ ) {
268275 const {
269276 project,
270277 ctx,
@@ -291,10 +298,8 @@ export async function saveDiffFiles(args: CompareReportsArgs) {
291298 settings,
292299 } ) ,
293300 } ,
294- ...( settings . detectNewIssues && {
295- newIssues : await findNewIssues ( { ...args , diffFiles } ) ,
296- } ) ,
297- } ;
301+ ...( newIssues && { newIssues } ) ,
302+ } satisfies ProjectRunResult ;
298303}
299304
300305export async function saveReportFiles < T extends 'current' | 'previous' > ( args : {
@@ -536,25 +541,32 @@ export function configFromPatterns(
536541}
537542
538543export async function findNewIssues (
539- args : CompareReportsArgs & { diffFiles : OutputFiles } ,
544+ args : CompareReportsArgs ,
540545) : Promise < SourceFileIssue [ ] > {
541546 const {
542547 base,
543548 currReport,
544549 prevReport,
545- diffFiles,
550+ config,
551+ ctx,
546552 env : {
547553 git,
548554 settings : { logger } ,
549555 } ,
550556 } = args ;
551557
558+ const diffFiles = persistedFilesFromConfig ( config , {
559+ directory : ctx . directory ,
560+ isDiff : true ,
561+ } ) ;
562+
552563 await git . fetch ( 'origin' , base . ref , [ '--depth=1' ] ) ;
553564 const reportsDiff = await readFile ( diffFiles . json , 'utf8' ) ;
554565 const changedFiles = await listChangedFiles (
555566 { base : 'FETCH_HEAD' , head : 'HEAD' } ,
556567 git ,
557568 ) ;
569+
558570 const issues = filterRelevantIssues ( {
559571 currReport : JSON . parse ( currReport . content ) as Report ,
560572 prevReport : JSON . parse ( prevReport . content ) as Report ,
0 commit comments