Skip to content

Commit 3e6b450

Browse files
fix(server): honor submodule settings when creating worktrees (#15594)
1 parent 9d029a1 commit 3e6b450

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/server/src/git/GitManager.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {
3535
type SourceControlProviderKind,
3636
type SourceControlWritingStyleSettings,
3737
type ThreadId,
38+
type VcsCreateWorktreeInput,
39+
type VcsCreateWorktreeResult,
3840
} from "@t3tools/contracts";
3941
import {
4042
hasProjectSettingsOverrides,
@@ -103,6 +105,10 @@ interface SourceControlTextGenerationSettings {
103105
export class GitManager extends Context.Service<
104106
GitManager,
105107
{
108+
readonly createWorktree: (
109+
input: VcsCreateWorktreeInput,
110+
options?: GitVcsDriver.CreateWorktreeOptions,
111+
) => Effect.Effect<VcsCreateWorktreeResult, GitCommandError>;
106112
readonly status: (
107113
input: VcsStatusInput,
108114
) => Effect.Effect<VcsStatusResult, GitManagerServiceError>;
@@ -727,6 +733,19 @@ export const make = Effect.gen(function* () {
727733
);
728734
return resolveProjectSettings(settings, projectId).settings;
729735
});
736+
const createWorktree: GitManager["Service"]["createWorktree"] = Effect.fn(
737+
"GitManager.createWorktree",
738+
)(function* (input, options) {
739+
const submodules =
740+
options?.submodules !== undefined
741+
? options.submodules
742+
: yield* projectSettingsFor(input).pipe(
743+
Effect.map((settings) => settings.worktreeSubmodules),
744+
Effect.orElseSucceed(() => null),
745+
);
746+
return yield* gitCore.createWorktree(input, { ...options, submodules });
747+
});
748+
730749
const readRepositoryInstructions = (cwd: string, fileName: string) =>
731750
Effect.gen(function* () {
732751
const root = yield* fileSystem.realPath(cwd);
@@ -2849,6 +2868,7 @@ export const make = Effect.gen(function* () {
28492868
);
28502869

28512870
return GitManager.of({
2871+
createWorktree,
28522872
localStatus,
28532873
remoteStatus,
28542874
status,

‎apps/server/src/git/GitWorkflowService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export const make = Effect.gen(function* () {
347347
),
348348
createWorktree: (input, options) =>
349349
ensureGitCommand("GitWorkflowService.createWorktree", input.cwd).pipe(
350-
Effect.andThen(git.createWorktree(input, options)),
350+
Effect.andThen(gitManager.createWorktree(input, options)),
351351
),
352352
listLocalBranchNames: (cwd) =>
353353
ensureGitCommand("GitWorkflowService.listLocalBranchNames", cwd).pipe(

0 commit comments

Comments
 (0)