@@ -325,7 +325,7 @@ export class SbomCollector {
325325 console . error ( chalk . red ( `Force submission failed for ${ fullName } branch ${ b . name } : ${ ( subErr as Error ) . message } ` ) ) ;
326326 }
327327 }
328- const diff = await this . fetchDependencyReviewDiff ( org , repo . name , base , b . name , 1 ) ;
328+ const diff = await this . fetchDependencyReviewDiff ( org , repo . name , base , b . name , latestCommit , 1 ) ;
329329 branchDiffs . set ( b . name , diff ) ;
330330 }
331331 if ( branchDiffs . size ) sbom . branchDiffs = branchDiffs ;
@@ -495,10 +495,7 @@ export class SbomCollector {
495495 return branches ;
496496 }
497497
498- private async fetchDependencyReviewDiff ( org : string , repo : string , base : string , head : string , retries : number ) : Promise < BranchDependencyDiff > {
499- if ( retries <= 0 ) {
500- return { latestCommitDate : undefined , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes : [ ] , error : "Maximum retries exceeded" } ;
501- }
498+ private async fetchDependencyReviewDiff ( org : string , repo : string , base : string , head : string , latestCommit ?: { sha ?: string ; commitDate ?: string , retries : number } ) : Promise < BranchDependencyDiff > {
502499 if ( ! this . octokit ) throw new Error ( "No Octokit instance" ) ;
503500 try {
504501 const basehead = `${ base } ...${ head } ` ;
@@ -521,7 +518,7 @@ export class SbomCollector {
521518 } ;
522519 changes . push ( change ) ;
523520 }
524- return { latestCommitDate : new Date ( ) . toISOString ( ) , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes } ;
521+ return { latestCommitDate : latestCommit ?. commitDate || new Date ( ) . toISOString ( ) , base, head, retrievedAt : new Date ( ) . toISOString ( ) , changes } ;
525522 } catch ( e ) {
526523 const status = ( e as { status ?: number } ) ?. status ;
527524 let reason = e instanceof Error ? e . message : String ( e ) ;
@@ -535,7 +532,7 @@ export class SbomCollector {
535532 if ( ok ) {
536533 console . log ( chalk . blue ( `Snapshot submission attempted; waiting 3 seconds before retrying dependency review diff for ${ org } /${ repo } ${ base } ...${ head } ...` ) ) ;
537534 await new Promise ( r => setTimeout ( r , 3000 ) ) ;
538- return await this . fetchDependencyReviewDiff ( org , repo , base , head , retries -- ) ;
535+ return await this . fetchDependencyReviewDiff ( org , repo , base , head , latestCommit , retries -- ) ;
539536 }
540537 } catch ( subErr ) {
541538 console . error ( chalk . red ( `Snapshot submission failed for ${ org } /${ repo } branch ${ head } : ${ ( subErr as Error ) . message } ` ) ) ;
0 commit comments