@@ -32,6 +32,7 @@ import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
3232import { compactTraceAttributes } from "@t3tools/shared/observability" ;
3333import { decodeJsonResult } from "@t3tools/shared/schemaJson" ;
3434import { parseT3ProjectFile } from "@t3tools/shared/t3ProjectFile" ;
35+ import { resolveProjectFileBackedSetting } from "@t3tools/shared/projectSettings" ;
3536import { gitCommandDuration , gitCommandsTotal , withMetrics } from "../observability/Metrics.ts" ;
3637import * as GitVcsDriver from "./GitVcsDriver.ts" ;
3738import {
@@ -3095,36 +3096,44 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
30953096 // them. Best-effort: the objects are usually already in the parent's
30963097 // `.git/modules`, but a first-ever clone needs the network, and failing to
30973098 // populate a submodule must not roll back the caller's thread. Repos with
3098- // hundreds of nested submodules opt out or stop at the top level through
3099- // t3.json, read from the checkout that was just created .
3099+ // hundreds of nested submodules opt out or stop at the top level; the
3100+ // caller resolves that from settings, or the checkout's t3.json decides .
31003101 const hasSubmodules = yield * fileSystem
31013102 . exists ( path . join ( worktreePath , ".gitmodules" ) )
31023103 . pipe ( Effect . orElseSucceed ( ( ) => false ) ) ;
3103- const submoduleMode = hasSubmodules
3104- ? yield * fileSystem . readFileString ( path . join ( worktreePath , T3_PROJECT_FILE_NAME ) ) . pipe (
3105- Effect . flatMap ( ( contents ) => {
3106- const file = parseT3ProjectFile ( contents ) ;
3107- return file === null
3108- ? Effect . logWarning ( "t3.json is invalid; initializing submodules recursively" , {
3109- worktreePath,
3110- } ) . pipe ( Effect . as ( "recursive" as const ) )
3111- : Effect . succeed ( file . worktreeSubmodules ?? "recursive" ) ;
3112- } ) ,
3113- Effect . orElseSucceed ( ( ) => "recursive" as const ) ,
3114- )
3115- : "none" ;
3116- if ( hasSubmodules && submoduleMode === "none" && progress ?. onSubmodulesDisabled ) {
3117- yield * progress . onSubmodulesDisabled ( ) ;
3104+ const submoduleMode = ! hasSubmodules
3105+ ? { value : "none" as const , source : "environment" as const }
3106+ : resolveProjectFileBackedSetting (
3107+ "worktreeSubmodules" ,
3108+ options ?. submodules ?? null ,
3109+ options ?. submodules != null
3110+ ? null
3111+ : yield * fileSystem . readFileString ( path . join ( worktreePath , T3_PROJECT_FILE_NAME ) ) . pipe (
3112+ Effect . flatMap ( ( contents ) => {
3113+ const file = parseT3ProjectFile ( contents ) ;
3114+ return file === null
3115+ ? Effect . logWarning ( "t3.json is invalid; initializing submodules recursively" , {
3116+ worktreePath,
3117+ } ) . pipe ( Effect . as ( null ) )
3118+ : Effect . succeed ( file ) ;
3119+ } ) ,
3120+ Effect . orElseSucceed ( ( ) => null ) ,
3121+ ) ,
3122+ ) ;
3123+ if ( hasSubmodules && submoduleMode . value === "none" && progress ?. onSubmodulesDisabled ) {
3124+ yield * progress . onSubmodulesDisabled ( {
3125+ source : submoduleMode . source === "t3.json" ? "t3.json" : "settings" ,
3126+ } ) ;
31183127 }
3119- if ( submoduleMode !== "none" ) {
3128+ if ( submoduleMode . value !== "none" ) {
31203129 if ( progress ?. onSubmodulesStarted ) {
31213130 yield * progress . onSubmodulesStarted ( ) ;
31223131 }
31233132 const onSubmoduleLine = progress ?. onSubmoduleLine ;
31243133 yield * runGit (
31253134 "GitVcsDriver.createWorktree.updateSubmodules" ,
31263135 worktreePath ,
3127- submoduleMode === "recursive"
3136+ submoduleMode . value === "recursive"
31283137 ? [ "submodule" , "update" , "--init" , "--recursive" ]
31293138 : [ "submodule" , "update" , "--init" ] ,
31303139 onSubmoduleLine
0 commit comments