Skip to content

Commit 55cb6b8

Browse files
committed
Extract isOverlayAnalysisFeatureEnabled()
1 parent 4bdb7fe commit 55cb6b8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/config-utils.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,23 @@ function parseQueriesFromInput(
646646
return trimmedInput.split(",").map((query) => ({ uses: query.trim() }));
647647
}
648648

649+
async function isOverlayAnalysisFeatureEnabled(
650+
repository: RepositoryNwo,
651+
features: FeatureEnablement,
652+
codeql: CodeQL,
653+
): Promise<boolean> {
654+
// TODO: Remove the repository owner check once support for overlay analysis
655+
// stabilizes, and no more backward-incompatible changes are expected.
656+
if (!["github", "dsp-testing"].includes(repository.owner)) {
657+
return false;
658+
}
659+
if (!(await features.getValue(Feature.OverlayAnalysis, codeql))) {
660+
return false;
661+
}
662+
// TODO: Add per-language feature checks here
663+
return true;
664+
}
665+
649666
/**
650667
* Calculate and validate the overlay database mode and caching to use.
651668
*
@@ -696,10 +713,7 @@ export async function getOverlayDatabaseMode(
696713
"from the CODEQL_OVERLAY_DATABASE_MODE environment variable.",
697714
);
698715
} else if (
699-
// TODO: Remove the repository owner check once support for overlay analysis
700-
// stabilizes, and no more backward-incompatible changes are expected.
701-
["github", "dsp-testing"].includes(repository.owner) &&
702-
(await features.getValue(Feature.OverlayAnalysis, codeql))
716+
await isOverlayAnalysisFeatureEnabled(repository, features, codeql)
703717
) {
704718
if (isAnalyzingPullRequest()) {
705719
overlayDatabaseMode = OverlayDatabaseMode.Overlay;

0 commit comments

Comments
 (0)