Small refactoring of shouldBypassToolcache
This commit is contained in:
parent
eb19ecbad1
commit
102e01da36
6 changed files with 43 additions and 40 deletions
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
|
|
@ -479,7 +479,7 @@ async function getRawLanguages(languagesInput, repository, logger) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
autodetected = true;
|
autodetected = true;
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain all languages in the repo that can be analysed
|
||||||
rawLanguages = (await getLanguagesInRepo(repository, logger));
|
rawLanguages = (await getLanguagesInRepo(repository, logger));
|
||||||
}
|
}
|
||||||
return { rawLanguages, autodetected };
|
return { rawLanguages, autodetected };
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
32
lib/util.js
generated
32
lib/util.js
generated
|
|
@ -728,23 +728,23 @@ async function shouldBypassToolcache(featuresEnablement, codeqlUrl, languagesInp
|
||||||
if (await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheEnabled)) {
|
if (await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheEnabled)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let bypass = false;
|
|
||||||
// Check if the toolcache is disabled for kotlin and swift.
|
// Check if the toolcache is disabled for kotlin and swift.
|
||||||
if (await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheKotlinSwiftEnabled)) {
|
if (!(await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheKotlinSwiftEnabled))) {
|
||||||
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
return false;
|
||||||
const { rawLanguages, autodetected } = await (0, config_utils_1.getRawLanguages)(languagesInput, repository, logger);
|
}
|
||||||
bypass = rawLanguages.some((lang) => languages_1.KOTLIN_SWIFT_BYPASS.includes(lang));
|
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
||||||
if (bypass) {
|
const { rawLanguages, autodetected } = await (0, config_utils_1.getRawLanguages)(languagesInput, repository, logger);
|
||||||
logger.info(`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`);
|
let bypass = rawLanguages.some((lang) => languages_1.KOTLIN_SWIFT_BYPASS.includes(lang));
|
||||||
}
|
if (bypass) {
|
||||||
else if (!autodetected && rawLanguages.includes(languages_1.Language.java)) {
|
logger.info(`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`);
|
||||||
// special case: java was explicitly specified, but there might be
|
}
|
||||||
// some kotlin in the repository, so we need to make a request for that.
|
else if (!autodetected && rawLanguages.includes(languages_1.Language.java)) {
|
||||||
const langsInRepo = await (0, config_utils_1.getLanguagesInRepo)(repository, logger);
|
// special case: java was explicitly specified, but there might be
|
||||||
if (langsInRepo.includes("kotlin")) {
|
// some kotlin in the repository, so we need to make a request for that.
|
||||||
logger.info(`Bypassing toolcache for kotlin.`);
|
const langsInRepo = await (0, config_utils_1.getLanguagesInRepo)(repository, logger);
|
||||||
bypass = true;
|
if (langsInRepo.includes("kotlin")) {
|
||||||
}
|
logger.info(`Bypassing toolcache for kotlin.`);
|
||||||
|
bypass = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bypass;
|
return bypass;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -973,7 +973,7 @@ export async function getRawLanguages(
|
||||||
} else {
|
} else {
|
||||||
autodetected = true;
|
autodetected = true;
|
||||||
|
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain all languages in the repo that can be analysed
|
||||||
rawLanguages = (await getLanguagesInRepo(repository, logger)) as string[];
|
rawLanguages = (await getLanguagesInRepo(repository, logger)) as string[];
|
||||||
}
|
}
|
||||||
return { rawLanguages, autodetected };
|
return { rawLanguages, autodetected };
|
||||||
|
|
|
||||||
43
src/util.ts
43
src/util.ts
|
|
@ -861,30 +861,33 @@ export async function shouldBypassToolcache(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bypass = false;
|
|
||||||
// Check if the toolcache is disabled for kotlin and swift.
|
// Check if the toolcache is disabled for kotlin and swift.
|
||||||
if (
|
if (
|
||||||
await featuresEnablement.getValue(Feature.BypassToolcacheKotlinSwiftEnabled)
|
!(await featuresEnablement.getValue(
|
||||||
|
Feature.BypassToolcacheKotlinSwiftEnabled
|
||||||
|
))
|
||||||
) {
|
) {
|
||||||
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
return false;
|
||||||
const { rawLanguages, autodetected } = await getRawLanguages(
|
}
|
||||||
languagesInput,
|
|
||||||
repository,
|
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
||||||
logger
|
const { rawLanguages, autodetected } = await getRawLanguages(
|
||||||
|
languagesInput,
|
||||||
|
repository,
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
let bypass = rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
|
||||||
|
if (bypass) {
|
||||||
|
logger.info(
|
||||||
|
`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`
|
||||||
);
|
);
|
||||||
bypass = rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
|
} else if (!autodetected && rawLanguages.includes(Language.java)) {
|
||||||
if (bypass) {
|
// special case: java was explicitly specified, but there might be
|
||||||
logger.info(
|
// some kotlin in the repository, so we need to make a request for that.
|
||||||
`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`
|
const langsInRepo = await getLanguagesInRepo(repository, logger);
|
||||||
);
|
if (langsInRepo.includes("kotlin")) {
|
||||||
} else if (!autodetected && rawLanguages.includes(Language.java)) {
|
logger.info(`Bypassing toolcache for kotlin.`);
|
||||||
// special case: java was explicitly specified, but there might be
|
bypass = true;
|
||||||
// some kotlin in the repository, so we need to make a request for that.
|
|
||||||
const langsInRepo = await getLanguagesInRepo(repository, logger);
|
|
||||||
if (langsInRepo.includes("kotlin")) {
|
|
||||||
logger.info(`Bypassing toolcache for kotlin.`);
|
|
||||||
bypass = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bypass;
|
return bypass;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue