Skip to content

Commit 5b00aaf

Browse files
committed
Sort out retries parameter and handling skipping submission
1 parent e103f8a commit 5b00aaf

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/componentSubmission.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function submitSnapshotIfPossible(opts: SubmitOpts): Promise<boolea
7070
// Create temp dir and sparse checkout only manifest files according to selected languages
7171
if (!intersect.length) {
7272
// No matching languages, skip submission
73-
return false;
73+
return true;
7474
}
7575
console.debug(chalk.green(`Sparse checkout into ${tmp} for languages: ${intersect.join(', ')}`));
7676

src/sbomCollector.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,15 @@ export class SbomCollector {
318318
if (this.opts.forceSubmission) {
319319
try {
320320
console.debug(chalk.blue(`Force-submission enabled: submitting component snapshot for ${fullName} branch ${b.name}...`));
321-
await submitSnapshotIfPossible({ octokit: this.octokit, owner: org, repo: repo.name, branch: b.name, languages: this.opts.submitLanguages, quiet: this.opts.quiet, componentDetectionBinPath: this.opts.componentDetectionBinPath });
322-
// brief delay to allow snapshot ingestion
323-
await new Promise(r => setTimeout(r, 1500));
321+
if (await submitSnapshotIfPossible({ octokit: this.octokit, owner: org, repo: repo.name, branch: b.name, languages: this.opts.submitLanguages, quiet: this.opts.quiet, componentDetectionBinPath: this.opts.componentDetectionBinPath })) {
322+
// brief delay to allow snapshot ingestion
323+
await new Promise(r => setTimeout(r, 1500));
324+
}
324325
} catch (subErr) {
325326
console.error(chalk.red(`Force submission failed for ${fullName} branch ${b.name}: ${(subErr as Error).message}`));
326327
}
327328
}
328-
const diff = await this.fetchDependencyReviewDiff(org, repo.name, base, b.name, latestCommit, 1);
329+
const diff = await this.fetchDependencyReviewDiff(org, repo.name, base, b.name, 1, latestCommit);
329330
branchDiffs.set(b.name, diff);
330331
}
331332
if (branchDiffs.size) sbom.branchDiffs = branchDiffs;
@@ -499,7 +500,7 @@ export class SbomCollector {
499500
return branches;
500501
}
501502

502-
private async fetchDependencyReviewDiff(org: string, repo: string, base: string, head: string, latestCommit?: { sha?: string; commitDate?: string, retries: number }): Promise<BranchDependencyDiff> {
503+
private async fetchDependencyReviewDiff(org: string, repo: string, base: string, head: string, retries: number, latestCommit?: { sha?: string; commitDate?: string }): Promise<BranchDependencyDiff> {
503504
if (!this.octokit) throw new Error("No Octokit instance");
504505
try {
505506
const basehead = `${base}...${head}`;
@@ -536,7 +537,7 @@ export class SbomCollector {
536537
if (ok) {
537538
console.log(chalk.blue(`Snapshot submission attempted; waiting 3 seconds before retrying dependency review diff for ${org}/${repo} ${base}...${head}...`));
538539
await new Promise(r => setTimeout(r, 3000));
539-
return await this.fetchDependencyReviewDiff(org, repo, base, head, latestCommit, retries--);
540+
return await this.fetchDependencyReviewDiff(org, repo, base, head, retries--, latestCommit);
540541
}
541542
} catch (subErr) {
542543
console.error(chalk.red(`Snapshot submission failed for ${org}/${repo} branch ${head}: ${(subErr as Error).message}`));

0 commit comments

Comments
 (0)