Skip to content
TypeScript

fix(server): honor submodule settings when creating worktrees (#15594)

Rahul Mishra3e6b45028cee
diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.ts
index 2829502c8cb..04433f26e53 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<VcsCreateWorktreeResult, GitCommandError>;
readonly status: (
input: VcsStatusInput,
) => Effect.Effect<VcsStatusResult, GitManagerServiceError>;
@@ -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 912e0c1f462..bc7f2d9fb2e 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(