@@ -15,6 +15,7 @@ import { join, dirname, parse } from "path";
1515import { tryGetQueryMetadata } from "../codeql-cli/query-metadata";
1616import { window as Window } from "vscode";
1717import { pluralize } from "../common/word";
18+ import { glob } from "glob";
1819
1920// Limit to three repos when generating autofixes so not sending
2021// too many requests to autofix. Since we only need to validate
@@ -273,6 +274,41 @@ async function processSelectedRepositories(
273274 logger: NotificationLogger,
274275): Promise<string[]> {
275276 const outputTextFiles: string[] = [];
276- // TODO
277+ await Promise.all(
278+ selectedRepoNames.map(async (nwo) =>
279+ withProgress(
280+ async (progressForRepo: ProgressCallback) => {
281+ // Get the sarif file.
282+ progressForRepo(progressUpdate(1, 3, `Getting sarif`));
283+ const repoStoragePath = join(variantAnalysisIdStoragePath, nwo);
284+ const sarifFile = await getSarifFile(repoStoragePath, nwo);
285+ },
286+ {
287+ title: `Processing ${nwo}`,
288+ cancellable: false,
289+ },
290+ ),
291+ ),
292+ );
293+
277294 return outputTextFiles;
278295}
296+
297+ /**
298+ * Gets the path to a SARIF file in a given `repoStoragePath`.
299+ */
300+ async function getSarifFile(
301+ repoStoragePath: string,
302+ nwo: string,
303+ ): Promise<string> {
304+ // Get results directory path.
305+ const repoResultsStoragePath = join(repoStoragePath, "results");
306+ // Find sarif file.
307+ const sarifFiles = await glob(`${repoResultsStoragePath}/**/*.sarif`);
308+ if (sarifFiles.length !== 1) {
309+ throw new Error(
310+ `Expected to find exactly one \`*.sarif\` file for ${nwo}, but found ${sarifFiles.length}.`,
311+ );
312+ }
313+ return sarifFiles[0];
314+ }
0 commit comments