Ignore default version flags with invalid version numbers
This commit is contained in:
parent
cdb90196f2
commit
a6dff04fe1
6 changed files with 75 additions and 12 deletions
14
lib/feature-flags.js
generated
14
lib/feature-flags.js
generated
|
|
@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const api_client_1 = require("./api-client");
|
||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||
const util = __importStar(require("./util"));
|
||||
|
|
@ -134,14 +135,19 @@ class GitHubFeatureFlags {
|
|||
this.logger = logger;
|
||||
/**/
|
||||
}
|
||||
static getCliVersionFromFeatureFlag(f) {
|
||||
getCliVersionFromFeatureFlag(f) {
|
||||
if (!f.startsWith(DEFAULT_VERSION_FEATURE_FLAG_PREFIX) ||
|
||||
!f.endsWith(DEFAULT_VERSION_FEATURE_FLAG_SUFFIX)) {
|
||||
return undefined;
|
||||
}
|
||||
return f
|
||||
const version = f
|
||||
.substring(DEFAULT_VERSION_FEATURE_FLAG_PREFIX.length, f.length - DEFAULT_VERSION_FEATURE_FLAG_SUFFIX.length)
|
||||
.replace(/_/g, ".");
|
||||
if (!semver.valid(version)) {
|
||||
this.logger.warning(`Ignoring feature flag ${f} as it does not specify a valid CodeQL version.`);
|
||||
return undefined;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === util.GitHubVariant.DOTCOM) {
|
||||
|
|
@ -159,9 +165,7 @@ class GitHubFeatureFlags {
|
|||
async getDefaultDotcomCliVersion() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response)
|
||||
.map(([f, isEnabled]) => isEnabled
|
||||
? GitHubFeatureFlags.getCliVersionFromFeatureFlag(f)
|
||||
: undefined)
|
||||
.map(([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : undefined)
|
||||
.filter((f) => f !== undefined)
|
||||
.map((f) => f);
|
||||
if (enabledFeatureFlagCliVersions.length === 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue