Ensure --overwrite flag is only passed once

This commit is contained in:
Henry Mercer 2024-04-16 18:08:46 +01:00
parent 8566d50a79
commit ade98b980a
3 changed files with 28 additions and 9 deletions

15
lib/codeql.js generated
View file

@ -292,7 +292,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
`--source-root=${sourceRoot}`, `--source-root=${sourceRoot}`,
...(await getLanguageAliasingArguments(this)), ...(await getLanguageAliasingArguments(this)),
...extraArgs, ...extraArgs,
...getExtraOptionsFromEnv(["database", "init"]), ...getExtraOptionsFromEnv(["database", "init"], {
ignoringOptions: ["--overwrite"],
}),
], { stdin: externalRepositoryToken }); ], { stdin: externalRepositoryToken });
}, },
async runAutobuild(language, enableDebugLogging) { async runAutobuild(language, enableDebugLogging) {
@ -442,7 +444,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"--expect-discarded-cache", "--expect-discarded-cache",
"--min-disk-free=1024", // Try to leave at least 1GB free "--min-disk-free=1024", // Try to leave at least 1GB free
"-v", "-v",
...getExtraOptionsFromEnv(["database", "run-queries"]), ...getExtraOptionsFromEnv(["database", "run-queries"], {
ignoringOptions: ["--expect-discarded-cache"],
}),
]; ];
if (await util.codeQlVersionAbove(this, feature_flags_1.CODEQL_VERSION_FINE_GRAINED_PARALLELISM)) { if (await util.codeQlVersionAbove(this, feature_flags_1.CODEQL_VERSION_FINE_GRAINED_PARALLELISM)) {
codeqlArgs.push("--intra-layer-parallelism"); codeqlArgs.push("--intra-layer-parallelism");
@ -692,10 +696,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
exports.getCodeQLForCmd = getCodeQLForCmd; exports.getCodeQLForCmd = getCodeQLForCmd;
/** /**
* Gets the options for `path` of `options` as an array of extra option strings. * Gets the options for `path` of `options` as an array of extra option strings.
*
* @param ignoringOptions Options that should be ignored, for example because they have already
* been passed and it is an error to pass them more than once.
*/ */
function getExtraOptionsFromEnv(paths) { function getExtraOptionsFromEnv(paths, { ignoringOptions } = {}) {
const options = util.getExtraOptionsEnvParam(); const options = util.getExtraOptionsEnvParam();
return getExtraOptions(options, paths, []); return getExtraOptions(options, paths, []).filter((option) => !ignoringOptions?.includes(option));
} }
/** /**
* Gets `options` as an array of extra option strings. * Gets `options` as an array of extra option strings.

File diff suppressed because one or more lines are too long

View file

@ -620,7 +620,9 @@ export async function getCodeQLForCmd(
`--source-root=${sourceRoot}`, `--source-root=${sourceRoot}`,
...(await getLanguageAliasingArguments(this)), ...(await getLanguageAliasingArguments(this)),
...extraArgs, ...extraArgs,
...getExtraOptionsFromEnv(["database", "init"]), ...getExtraOptionsFromEnv(["database", "init"], {
ignoringOptions: ["--overwrite"],
}),
], ],
{ stdin: externalRepositoryToken }, { stdin: externalRepositoryToken },
); );
@ -800,7 +802,9 @@ export async function getCodeQLForCmd(
"--expect-discarded-cache", "--expect-discarded-cache",
"--min-disk-free=1024", // Try to leave at least 1GB free "--min-disk-free=1024", // Try to leave at least 1GB free
"-v", "-v",
...getExtraOptionsFromEnv(["database", "run-queries"]), ...getExtraOptionsFromEnv(["database", "run-queries"], {
ignoringOptions: ["--expect-discarded-cache"],
}),
]; ];
if ( if (
await util.codeQlVersionAbove( await util.codeQlVersionAbove(
@ -1139,10 +1143,18 @@ export async function getCodeQLForCmd(
/** /**
* Gets the options for `path` of `options` as an array of extra option strings. * Gets the options for `path` of `options` as an array of extra option strings.
*
* @param ignoringOptions Options that should be ignored, for example because they have already
* been passed and it is an error to pass them more than once.
*/ */
function getExtraOptionsFromEnv(paths: string[]) { function getExtraOptionsFromEnv(
paths: string[],
{ ignoringOptions }: { ignoringOptions?: string[] } = {},
) {
const options: ExtraOptions = util.getExtraOptionsEnvParam(); const options: ExtraOptions = util.getExtraOptionsEnvParam();
return getExtraOptions(options, paths, []); return getExtraOptions(options, paths, []).filter(
(option) => !ignoringOptions?.includes(option),
);
} }
/** /**