@@ -315,7 +315,7 @@ export class SbomCollector {
315315 console . error ( chalk . red ( `Force submission failed for ${ fullName } branch ${ b . name } : ${ ( subErr as Error ) . message } ` ) ) ;
316316 }
317317 }
318- const diff = await this . fetchDependencyReviewDiff ( org , repo . name , base , b . name ) ;
318+ const diff = await this . fetchDependencyReviewDiff ( org , repo . name , base , b . name , latestCommit ) ;
319319 branchDiffs . set ( b . name , diff ) ;
320320 }
321321 if ( branchDiffs . size ) sbom . branchDiffs = branchDiffs ;
@@ -483,7 +483,7 @@ export class SbomCollector {
483483 return branches ;
484484 }
485485
486- private async fetchDependencyReviewDiff ( org : string , repo : string , base : string , head : string ) : Promise < BranchDependencyDiff > {
486+ private async fetchDependencyReviewDiff ( org : string , repo : string , base : string , head : string , latestCommit ?: { sha ?: string ; commitDate ?: string } ) : Promise < BranchDependencyDiff > {
487487 if ( ! this . octokit ) throw new Error ( "No Octokit instance" ) ;
488488 try {
489489 const basehead = `${ base } ...${ head } ` ;
@@ -506,7 +506,7 @@ export class SbomCollector {
506506 } ;
507507 changes . push ( change ) ;
508508 }
509- return { latestCommitDate : new Date ( ) . toISOString ( ) , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes } ;
509+ return { latestCommitDate : latestCommit ?. commitDate || new Date ( ) . toISOString ( ) , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes } ;
510510 } catch ( e ) {
511511 const status = ( e as { status ?: number } ) ?. status ;
512512 let reason = e instanceof Error ? e . message : String ( e ) ;
@@ -520,15 +520,15 @@ export class SbomCollector {
520520 if ( ok ) {
521521 console . log ( chalk . blue ( `Snapshot submission attempted; waiting 3 seconds before retrying dependency review diff for ${ org } /${ repo } ${ base } ...${ head } ...` ) ) ;
522522 await new Promise ( r => setTimeout ( r , 3000 ) ) ;
523- return await this . fetchDependencyReviewDiff ( org , repo , base , head ) ;
523+ return await this . fetchDependencyReviewDiff ( org , repo , base , head , latestCommit ) ;
524524 }
525525 } catch ( subErr ) {
526526 console . error ( chalk . red ( `Snapshot submission failed for ${ org } /${ repo } branch ${ head } : ${ ( subErr as Error ) . message } ` ) ) ;
527527 reason += ` (submission attempt failed: ${ ( subErr as Error ) . message } )` ;
528528 }
529529 }
530530 }
531- return { latestCommitDate : new Date ( ) . toISOString ( ) , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes : [ ] , error : reason } ;
531+ return { latestCommitDate : latestCommit ?. commitDate || new Date ( ) . toISOString ( ) , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes : [ ] , error : reason } ;
532532 }
533533 }
534534
0 commit comments