@@ -6,19 +6,15 @@ import * as io from "@actions/io";
66import * as del from "del" ;
77import * as yaml from "js-yaml" ;
88
9- import { getTemporaryDirectory , PullRequestBranches } from "./actions-util" ;
9+ import { getTemporaryDirectory } from "./actions-util" ;
1010import * as analyses from "./analyses" ;
1111// (getApiClient import removed; no longer needed after diff refactor)
1212import { setupCppAutobuild } from "./autobuild" ;
1313import { type CodeQL } from "./codeql" ;
1414import * as configUtils from "./config-utils" ;
1515import { getJavaTempDependencyDir } from "./dependency-caching" ;
1616import { addDiagnostic , makeDiagnostic } from "./diagnostics" ;
17- import {
18- DiffThunkRange ,
19- writeDiffRangesJsonFile ,
20- getPullRequestEditedDiffRanges ,
21- } from "./diff-informed-analysis-utils" ;
17+ import { DiffThunkRange , readDiffRangesJsonFile } from "./diff-informed-analysis-utils" ;
2218import { EnvVar } from "./environment" ;
2319import { FeatureEnablement , Feature } from "./feature-flags" ;
2420import { KnownLanguage , Language } from "./languages" ;
@@ -284,17 +280,35 @@ async function finalizeDatabaseCreation(
284280 * the diff range information, or `undefined` if the feature is disabled.
285281 */
286282export async function setupDiffInformedQueryRun (
287- branches : PullRequestBranches ,
288283 logger : Logger ,
289284) : Promise < string | undefined > {
290285 return await withGroupAsync (
291286 "Generating diff range extension pack" ,
292287 async ( ) => {
288+ // Only use precomputed diff ranges; never recompute here.
289+ let diffRanges : DiffThunkRange [ ] | undefined ;
290+ try {
291+ diffRanges = readDiffRangesJsonFile ( logger ) ;
292+ } catch ( e ) {
293+ logger . debug (
294+ `Failed to read precomputed diff ranges: ${ util . getErrorMessage ( e ) } ` ,
295+ ) ;
296+ diffRanges = undefined ;
297+ }
298+
299+ if ( diffRanges === undefined ) {
300+ logger . info (
301+ "No precomputed diff ranges found; skipping diff-informed analysis stage." ,
302+ ) ;
303+ return undefined ;
304+ }
305+
306+ const fileCount = new Set ( diffRanges . filter ( ( r ) => r . path ) . map ( ( r ) => r . path ) ) . size ;
293307 logger . info (
294- `Calculating diff ranges for ${ branches . base } ... ${ branches . head } ` ,
308+ `Using precomputed diff ranges ( ${ diffRanges . length } ranges across ${ fileCount } files). ` ,
295309 ) ;
296- const diffRanges = await getPullRequestEditedDiffRanges ( branches , logger ) ;
297- const packDir = writeDiffRangeDataExtensionPack ( logger , diffRanges ) ;
310+
311+ const packDir = writeDiffRangeDataExtensionPack ( logger , diffRanges ) ;
298312 if ( packDir === undefined ) {
299313 logger . warning (
300314 "Cannot create diff range extension pack for diff-informed queries; " +
@@ -392,9 +406,6 @@ extensions:
392406 `Wrote pr-diff-range extension pack to ${ extensionFilePath } :\n${ extensionContents } ` ,
393407 ) ;
394408
395- // Write the diff ranges to a JSON file, for action-side alert filtering by the
396- // upload-lib module.
397- writeDiffRangesJsonFile ( logger , ranges ) ;
398409
399410 return diffRangeDir ;
400411}
0 commit comments