Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,6 @@ export function getVariantAnalysisDefaultResultsSort(): SortKey {
*/
const ACTION_BRANCH = new Setting("actionBranch", VARIANT_ANALYSIS_SETTING);

export const VARIANT_ANALYSIS_ENABLE_GHEC_DR = new Setting(
"enableGhecDr",
VARIANT_ANALYSIS_SETTING,
);

export function getActionBranch(): string {
return ACTION_BRANCH.getValue<string>() || "main";
}
Expand Down
14 changes: 3 additions & 11 deletions extensions/ql-vscode/src/variant-analysis/ghec-dr.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import {
VARIANT_ANALYSIS_ENABLE_GHEC_DR,
hasEnterpriseUri,
hasGhecDrUri,
} from "../config";
import { hasEnterpriseUri, hasGhecDrUri } from "../config";

/**
* Determines whether MRVA should be enabled or not for the current GitHub host.
* MRVA is enabled on github.com and GHEC-DR.
* This is based on the `github-enterprise.uri` setting.
*/
export function isVariantAnalysisEnabledForGitHubHost(): boolean {
return (
// MRVA is always enabled on github.com
!hasEnterpriseUri() ||
// MRVA can be enabled on GHEC-DR using a feature flag
(hasGhecDrUri() && !!VARIANT_ANALYSIS_ENABLE_GHEC_DR.getValue<boolean>())
);
return !hasEnterpriseUri() || hasGhecDrUri();
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,25 @@
import { ConfigurationTarget } from "vscode";
import {
VARIANT_ANALYSIS_ENABLE_GHEC_DR,
VSCODE_GITHUB_ENTERPRISE_URI_SETTING,
} from "../../../../src/config";
import { VSCODE_GITHUB_ENTERPRISE_URI_SETTING } from "../../../../src/config";
import { isVariantAnalysisEnabledForGitHubHost } from "../../../../src/variant-analysis/ghec-dr";

describe("checkVariantAnalysisEnabled", () => {
it("returns cleanly when no enterprise URI is set", async () => {
it("returns true when no enterprise URI is set", async () => {
expect(isVariantAnalysisEnabledForGitHubHost()).toBe(true);
});

it("returns false when GHES enterprise URI is set and variant analysis feature flag is not set", async () => {
it("returns false when GHES enterprise URI is set", async () => {
await VSCODE_GITHUB_ENTERPRISE_URI_SETTING.updateValue(
"https://github.example.com",
ConfigurationTarget.Global,
);
expect(isVariantAnalysisEnabledForGitHubHost()).toBe(false);
});

it("returns false when GHES enterprise URI is set and variant analysis feature flag is set", async () => {
await VSCODE_GITHUB_ENTERPRISE_URI_SETTING.updateValue(
"https://github.example.com",
ConfigurationTarget.Global,
);
await VARIANT_ANALYSIS_ENABLE_GHEC_DR.updateValue(
"true",
ConfigurationTarget.Global,
);
expect(isVariantAnalysisEnabledForGitHubHost()).toBe(false);
});

it("returns false when GHEC-DR URI is set and variant analysis feature flag is not set", async () => {
it("returns true when a GHEC-DR URI is set", async () => {
await VSCODE_GITHUB_ENTERPRISE_URI_SETTING.updateValue(
"https://example.ghe.com",
ConfigurationTarget.Global,
);
expect(isVariantAnalysisEnabledForGitHubHost()).toBe(false);
});

it("returns true when GHEC-DR URI is set and variant analysis feature flag is set", async () => {
await VSCODE_GITHUB_ENTERPRISE_URI_SETTING.updateValue(
"https://example.ghe.com",
ConfigurationTarget.Global,
);
await VARIANT_ANALYSIS_ENABLE_GHEC_DR.updateValue(
"true",
ConfigurationTarget.Global,
);
expect(isVariantAnalysisEnabledForGitHubHost()).toBe(true);
});
});