From 88a7e5118e127456d32f62e55c279cc8ef74e80d Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 27 Mar 2026 18:52:56 +0000 Subject: [PATCH] Don't disable if we don't need the git version --- lib/init-action.js | 24 +++++++++++++----------- src/config-utils.test.ts | 3 ++- src/config-utils.ts | 39 ++++++++++++++++++++------------------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/lib/init-action.js b/lib/init-action.js index 60137d472..e31c24e7a 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -107054,17 +107054,19 @@ async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDataba ); return new Failure("no-git-root" /* NoGitRoot */); } - if (gitVersion === void 0) { - logger.warning( - `Cannot build an ${overlayDatabaseMode} database because the Git version could not be determined. Falling back to creating a normal full database instead.` - ); - return new Failure("incompatible-git" /* IncompatibleGit */); - } - if (await hasSubmodules(sourceRoot) && !gitVersion.isAtLeast(GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES)) { - logger.warning( - `Cannot build an ${overlayDatabaseMode} database because the repository has submodules and the installed Git version is older than ${GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES}. Falling back to creating a normal full database instead.` - ); - return new Failure("incompatible-git" /* IncompatibleGit */); + if (await hasSubmodules(sourceRoot)) { + if (gitVersion === void 0) { + logger.warning( + `Cannot build an ${overlayDatabaseMode} database because the repository has submodules and the Git version could not be determined. Falling back to creating a normal full database instead.` + ); + return new Failure("incompatible-git" /* IncompatibleGit */); + } + if (!gitVersion.isAtLeast(GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES)) { + logger.warning( + `Cannot build an ${overlayDatabaseMode} database because the repository has submodules and the installed Git version is older than ${GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES}. Falling back to creating a normal full database instead.` + ); + return new Failure("incompatible-git" /* IncompatibleGit */); + } } return new Success({ overlayDatabaseMode, diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index 74cdc4f90..59476118d 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -1948,10 +1948,11 @@ test.serial( test.serial( checkOverlayEnablementMacro, - "Fallback when git version cannot be determined", + "Fallback when git version cannot be determined and repo has submodules", { overlayDatabaseEnvVar: "overlay", gitVersion: undefined, + hasSubmodules: true, }, { disabledReason: OverlayDisabledReason.IncompatibleGit, diff --git a/src/config-utils.ts b/src/config-utils.ts index 654f745d1..6d705bc31 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -978,25 +978,26 @@ async function validateOverlayDatabaseMode( ); return new Failure(OverlayDisabledReason.NoGitRoot); } - if (gitVersion === undefined) { - logger.warning( - `Cannot build an ${overlayDatabaseMode} database because ` + - "the Git version could not be determined. " + - "Falling back to creating a normal full database instead.", - ); - return new Failure(OverlayDisabledReason.IncompatibleGit); - } - if ( - (await hasSubmodules(sourceRoot)) && - !gitVersion.isAtLeast(GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES) - ) { - logger.warning( - `Cannot build an ${overlayDatabaseMode} database because ` + - "the repository has submodules and the installed Git version is older " + - `than ${GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES}. ` + - "Falling back to creating a normal full database instead.", - ); - return new Failure(OverlayDisabledReason.IncompatibleGit); + if (await hasSubmodules(sourceRoot)) { + if (gitVersion === undefined) { + logger.warning( + `Cannot build an ${overlayDatabaseMode} database because ` + + "the repository has submodules and the Git version could not be determined. " + + "Falling back to creating a normal full database instead.", + ); + return new Failure(OverlayDisabledReason.IncompatibleGit); + } + if ( + !gitVersion.isAtLeast(GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES) + ) { + logger.warning( + `Cannot build an ${overlayDatabaseMode} database because ` + + "the repository has submodules and the installed Git version is older " + + `than ${GIT_MINIMUM_VERSION_FOR_OVERLAY_WITH_SUBMODULES}. ` + + "Falling back to creating a normal full database instead.", + ); + return new Failure(OverlayDisabledReason.IncompatibleGit); + } } return new Success({