@@ -288,16 +288,17 @@ function getPullRequestBranches(): PullRequestBranches | undefined {
288
288
}
289
289
290
290
/**
291
- * Set up the diff-informed analysis feature .
291
+ * Check if the action should perform diff-informed analysis.
292
292
*
293
- * @returns Absolute path to the directory containing the extension pack for
294
- * the diff range information, or `undefined` if the feature is disabled.
293
+ * @returns If the action should perform diff-informed analysis, return
294
+ * the base and head branches that should be used to compute the diff ranges.
295
+ * Otherwise return `undefined`.
295
296
*/
296
- export async function setupDiffInformedQueryRun (
297
+ async function shouldPerformDiffInformedAnalysis (
297
298
codeql : CodeQL ,
298
- logger : Logger ,
299
299
features : FeatureEnablement ,
300
- ) : Promise < string | undefined > {
300
+ logger : Logger ,
301
+ ) : Promise < PullRequestBranches | undefined > {
301
302
if ( ! ( await features . getValue ( Feature . DiffInformedQueries , codeql ) ) ) {
302
303
return undefined ;
303
304
}
@@ -308,6 +309,27 @@ export async function setupDiffInformedQueryRun(
308
309
"Not performing diff-informed analysis " +
309
310
"because we are not analyzing a pull request." ,
310
311
) ;
312
+ }
313
+ return branches ;
314
+ }
315
+
316
+ /**
317
+ * Set up the diff-informed analysis feature.
318
+ *
319
+ * @returns Absolute path to the directory containing the extension pack for
320
+ * the diff range information, or `undefined` if the feature is disabled.
321
+ */
322
+ export async function setupDiffInformedQueryRun (
323
+ codeql : CodeQL ,
324
+ logger : Logger ,
325
+ features : FeatureEnablement ,
326
+ ) : Promise < string | undefined > {
327
+ const branches = await shouldPerformDiffInformedAnalysis (
328
+ codeql ,
329
+ features ,
330
+ logger ,
331
+ ) ;
332
+ if ( ! branches ) {
311
333
return undefined ;
312
334
}
313
335
0 commit comments