@@ -15,6 +15,7 @@ import { join, dirname, parse } from "path";
15
15
import { tryGetQueryMetadata } from "../codeql-cli/query-metadata" ;
16
16
import { window as Window } from "vscode" ;
17
17
import { pluralize } from "../common/word" ;
18
+ import { glob } from "glob" ;
18
19
19
20
// Limit to three repos when generating autofixes so not sending
20
21
// too many requests to autofix. Since we only need to validate
@@ -273,6 +274,41 @@ async function processSelectedRepositories(
273
274
logger : NotificationLogger ,
274
275
) : Promise < string [ ] > {
275
276
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
+
277
294
return outputTextFiles ;
278
295
}
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