@@ -9,8 +9,11 @@ import * as Path from "effect/Path";
99import * as ServerConfig from "../config.ts" ;
1010import * as GitVcsDriver from "../vcs/GitVcsDriver.ts" ;
1111import * as VcsProcess from "../vcs/VcsProcess.ts" ;
12- import * as AzureDevOpsChangeRequestTemplate from "@t3tools/source-control-azure-devops/server/azureDevOpsChangeRequestTemplate" ;
13- import * as GitLabChangeRequestTemplate from "@t3tools/source-control-gitlab/server/gitLabChangeRequestTemplate" ;
12+ import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli" ;
13+ import * as AzureDevOpsSourceControlProvider from "@t3tools/source-control-azure-devops/server/AzureDevOpsSourceControlProvider" ;
14+ import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli" ;
15+ import * as GitLabSourceControlProvider from "@t3tools/source-control-gitlab/server/GitLabSourceControlProvider" ;
16+ import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost" ;
1417
1518const layerTest = GitVcsDriver . layer . pipe (
1619 Layer . provide (
@@ -61,20 +64,34 @@ const commitAll = (cwd: string) =>
6164 yield * runGit ( cwd , [ "commit" , "--allow-empty" , "-m" , "Add templates" ] ) ;
6265 } ) ;
6366
67+ // Each provider is built with test layers for its CLI and host only. The host's git is the real
68+ // driver, so templates are read from real commits.
6469const detectGitLab = ( cwd : string , treeish = "HEAD" ) =>
6570 Effect . gen ( function * ( ) {
6671 const git = yield * GitVcsDriver . GitVcsDriver ;
67- return Option . getOrUndefined (
68- yield * GitLabChangeRequestTemplate . detect ( cwd , treeish , git . execute ) ,
72+ const provider = yield * GitLabSourceControlProvider . make . pipe (
73+ Effect . provide (
74+ Layer . mergeAll (
75+ Layer . mock ( GitLabCli . GitLabCli ) ( { } ) ,
76+ TestSourceControlHost . layer ( { git : { execute : git . execute } } ) ,
77+ ) ,
78+ ) ,
6979 ) ;
80+ return Option . getOrUndefined ( yield * provider . readChangeRequestTemplate ! ( { cwd, treeish } ) ) ;
7081 } ) ;
7182
7283const detectAzureDevOps = ( cwd : string , treeish = "HEAD" ) =>
7384 Effect . gen ( function * ( ) {
7485 const git = yield * GitVcsDriver . GitVcsDriver ;
75- return Option . getOrUndefined (
76- yield * AzureDevOpsChangeRequestTemplate . detect ( cwd , treeish , git . execute ) ,
86+ const provider = yield * AzureDevOpsSourceControlProvider . make . pipe (
87+ Effect . provide (
88+ Layer . mergeAll (
89+ Layer . mock ( AzureDevOpsCli . AzureDevOpsCli ) ( { } ) ,
90+ TestSourceControlHost . layer ( { git : { execute : git . execute } } ) ,
91+ ) ,
92+ ) ,
7793 ) ;
94+ return Option . getOrUndefined ( yield * provider . readChangeRequestTemplate ! ( { cwd, treeish } ) ) ;
7895 } ) ;
7996
8097const MERGE_REQUEST_TEMPLATES = ".gitlab/merge_request_templates" ;
0 commit comments