File tree 2 files changed +35
-6
lines changed
2 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ import { setupCppAutobuild } from "./autobuild";
12
12
import { CodeQL , getCodeQL } from "./codeql" ;
13
13
import * as configUtils from "./config-utils" ;
14
14
import { addDiagnostic , makeDiagnostic } from "./diagnostics" ;
15
+ import {
16
+ DiffThunkRange ,
17
+ writeDiffRangesJsonFile ,
18
+ } from "./diff-filtering-utils" ;
15
19
import { EnvVar } from "./environment" ;
16
20
import { FeatureEnablement , Feature } from "./feature-flags" ;
17
21
import { isScannedLanguage , Language } from "./languages" ;
@@ -284,12 +288,6 @@ export async function setupDiffInformedQueryRun(
284
288
) ;
285
289
}
286
290
287
- interface DiffThunkRange {
288
- path : string ;
289
- startLine : number ;
290
- endLine : number ;
291
- }
292
-
293
291
/**
294
292
* Return the file line ranges that were added or modified in the pull request.
295
293
*
@@ -537,6 +535,10 @@ extensions:
537
535
`Wrote pr-diff-range extension pack to ${ extensionFilePath } :\n${ extensionContents } ` ,
538
536
) ;
539
537
538
+ // Write the diff ranges to a JSON file, for action-side alert filtering by the
539
+ // upload-lib module.
540
+ writeDiffRangesJsonFile ( logger , ranges ) ;
541
+
540
542
return diffRangeDir ;
541
543
}
542
544
Original file line number Diff line number Diff line change
1
+ import * as fs from "fs" ;
2
+ import * as path from "path" ;
3
+
4
+ import * as actionsUtil from "./actions-util" ;
5
+ import { Logger } from "./logging" ;
6
+
7
+ export interface DiffThunkRange {
8
+ path : string ;
9
+ startLine : number ;
10
+ endLine : number ;
11
+ }
12
+
13
+ function getDiffRangesJsonFilePath ( ) : string {
14
+ return path . join ( actionsUtil . getTemporaryDirectory ( ) , "pr-diff-range.json" ) ;
15
+ }
16
+
17
+ export function writeDiffRangesJsonFile (
18
+ logger : Logger ,
19
+ ranges : DiffThunkRange [ ] ,
20
+ ) : void {
21
+ const jsonContents = JSON . stringify ( ranges , null , 2 ) ;
22
+ const jsonFilePath = getDiffRangesJsonFilePath ( ) ;
23
+ fs . writeFileSync ( jsonFilePath , jsonContents ) ;
24
+ logger . debug (
25
+ `Wrote pr-diff-range JSON file to ${ jsonFilePath } :\n${ jsonContents } ` ,
26
+ ) ;
27
+ }
You can’t perform that action at this time.
0 commit comments