diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.ts index 2829502c8cbd8424d1077afedc7899fee62cef18..04433f26e5335e010b73faef4ba1c9d66ad81598 100644 --- a/apps/server/src/git/GitManager.ts +++ b/apps/server/src/git/GitManager.ts @@ -35,6 +35,8 @@ import { type SourceControlProviderKind, type SourceControlWritingStyleSettings, type ThreadId, + type VcsCreateWorktreeInput, + type VcsCreateWorktreeResult, } from "@t3tools/contracts"; import { hasProjectSettingsOverrides, @@ -103,6 +105,10 @@ interface SourceControlTextGenerationSettings { export class GitManager extends Context.Service< GitManager, { + readonly createWorktree: ( + input: VcsCreateWorktreeInput, + options?: GitVcsDriver.CreateWorktreeOptions, + ) => Effect.Effect; readonly status: ( input: VcsStatusInput, ) => Effect.Effect; @@ -727,6 +733,19 @@ export const make = Effect.gen(function* () { ); return resolveProjectSettings(settings, projectId).settings; }); + const createWorktree: GitManager["Service"]["createWorktree"] = Effect.fn( + "GitManager.createWorktree", + )(function* (input, options) { + const submodules = + options?.submodules !== undefined + ? options.submodules + : yield* projectSettingsFor(input).pipe( + Effect.map((settings) => settings.worktreeSubmodules), + Effect.orElseSucceed(() => null), + ); + return yield* gitCore.createWorktree(input, { ...options, submodules }); + }); + const readRepositoryInstructions = (cwd: string, fileName: string) => Effect.gen(function* () { const root = yield* fileSystem.realPath(cwd); @@ -2849,6 +2868,7 @@ export const make = Effect.gen(function* () { ); return GitManager.of({ + createWorktree, localStatus, remoteStatus, status, diff --git a/apps/server/src/git/GitWorkflowService.ts b/apps/server/src/git/GitWorkflowService.ts index 912e0c1f4620801dc5b061917c6c4f00205a0f4c..bc7f2d9fb2ea3fafce2fb969909075b9537a2b7d 100644 --- a/apps/server/src/git/GitWorkflowService.ts +++ b/apps/server/src/git/GitWorkflowService.ts @@ -347,7 +347,7 @@ export const make = Effect.gen(function* () { ), createWorktree: (input, options) => ensureGitCommand("GitWorkflowService.createWorktree", input.cwd).pipe( - Effect.andThen(git.createWorktree(input, options)), + Effect.andThen(gitManager.createWorktree(input, options)), ), listLocalBranchNames: (cwd) => ensureGitCommand("GitWorkflowService.listLocalBranchNames", cwd).pipe(