mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 01:08:46 +00:00
Prefer explicit env var to binary accessibility check
This commit is contained in:
+7
-5
@@ -54,7 +54,6 @@ import {
|
||||
getCodeQLMemoryLimit,
|
||||
getErrorMessage,
|
||||
isInTestMode,
|
||||
isBinaryAccessible,
|
||||
} from "./util";
|
||||
|
||||
export * from "./config/db-config";
|
||||
@@ -937,10 +936,13 @@ export async function initConfig(
|
||||
await logGitVersionTelemetry(config, gitVersion);
|
||||
} catch (e) {
|
||||
logger.warning(`Could not determine Git version: ${getErrorMessage(e)}`);
|
||||
// Throw the error in test mode so it's more visible, but tolerate cases
|
||||
// where the git binary is not present, for example because we're running
|
||||
// in a Docker container.
|
||||
if (isInTestMode() && (await isBinaryAccessible("git", logger))) {
|
||||
// Throw the error in test mode so it's more visible, unless the environment
|
||||
// variable is set to tolerate this, for example because we're running in a
|
||||
// Docker container where git may not be available.
|
||||
if (
|
||||
isInTestMode() &&
|
||||
process.env.CODEQL_ACTION_TOLERATE_MISSING_GIT_VERSION !== "true"
|
||||
) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,4 +129,10 @@ export enum EnvVar {
|
||||
* the workflow is valid and validation is not necessary.
|
||||
*/
|
||||
SKIP_WORKFLOW_VALIDATION = "CODEQL_ACTION_SKIP_WORKFLOW_VALIDATION",
|
||||
|
||||
/**
|
||||
* Whether to tolerate failure to determine the git version (only applicable in test mode).
|
||||
* Intended for use in environments where git may not be installed, such as Docker containers.
|
||||
*/
|
||||
TOLERATE_MISSING_GIT_VERSION = "CODEQL_ACTION_TOLERATE_MISSING_GIT_VERSION",
|
||||
}
|
||||
|
||||
@@ -40,9 +40,6 @@ export class GitVersionInfo {
|
||||
/**
|
||||
* Gets the version of Git installed on the system and throws an error if
|
||||
* the version cannot be determined.
|
||||
*
|
||||
* @returns The Git version string (e.g., "2.40.0").
|
||||
* @throws {Error} if the version could not be determined.
|
||||
*/
|
||||
export async function getGitVersionOrThrow(): Promise<GitVersionInfo> {
|
||||
const stdout = await runGitCommand(
|
||||
|
||||
Reference in New Issue
Block a user