Skip to content

Commit 2bcf42e

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Read 'repo_task.json' file
1 parent 2afd2ee commit 2bcf42e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

extensions/ql-vscode/src/variant-analysis/view-autofixes.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import {
33
defaultFilterSortState,
44
filterAndSortRepositoriesWithResults,
55
} from "./shared/variant-analysis-filter-sort";
6-
import type { VariantAnalysis } from "./shared/variant-analysis";
6+
import type {
7+
VariantAnalysis,
8+
VariantAnalysisRepositoryTask,
9+
} from "./shared/variant-analysis";
710
import type { Credentials } from "../common/authentication";
811
import type { NotificationLogger } from "../common/logging";
912
import type { App } from "../common/app";
@@ -16,6 +19,7 @@ import { tryGetQueryMetadata } from "../codeql-cli/query-metadata";
1619
import { window as Window } from "vscode";
1720
import { pluralize } from "../common/word";
1821
import { glob } from "glob";
22+
import { readRepoTask } from "./repo-tasks-store";
1923

2024
// Limit to three repos when generating autofixes so not sending
2125
// too many requests to autofix. Since we only need to validate
@@ -282,6 +286,17 @@ async function processSelectedRepositories(
282286
progressForRepo(progressUpdate(1, 3, `Getting sarif`));
283287
const repoStoragePath = join(variantAnalysisIdStoragePath, nwo);
284288
const sarifFile = await getSarifFile(repoStoragePath, nwo);
289+
290+
// Read the contents of the variant analysis' `repo_task.json` file,
291+
// and confirm that the `databaseCommitSha` and `resultCount` exist.
292+
const repoTask: VariantAnalysisRepositoryTask =
293+
await readRepoTask(repoStoragePath);
294+
if (!repoTask.databaseCommitSha) {
295+
throw new Error(`Missing database commit SHA for ${nwo}`);
296+
}
297+
if (!repoTask.resultCount) {
298+
throw new Error(`Missing variant analysis result count for ${nwo}`);
299+
}
285300
},
286301
{
287302
title: `Processing ${nwo}`,

0 commit comments

Comments
 (0)