@@ -42,7 +42,7 @@ import {
4242} from "@t3tools/contracts" ;
4343import * as DateTime from "effect/DateTime" ;
4444import * as GitHubApi from "../sourceControl/GitHubApi.ts" ;
45- import * as GitHubCli from "../sourceControl/GitHubCli .ts" ;
45+ import * as GitHubRepositoryApi from "../sourceControl/GitHubRepositoryApi .ts" ;
4646import { decodeGitHubPullRequestListJson } from "../sourceControl/gitHubPullRequests.ts" ;
4747import * as GitLabCli from "../sourceControl/GitLabCli.ts" ;
4848import * as TextGeneration from "../textGeneration/TextGeneration.ts" ;
@@ -92,7 +92,7 @@ interface FakeGhScenario {
9292 headRepositoryOwnerLogin ?: string | null ;
9393 } ;
9494 repositoryCloneUrls ?: Record < string , { url : string ; sshUrl : string } > ;
95- failWith ?: GitHubCli . GitHubCliError ;
95+ failWith ?: GitHubRepositoryApi . GitHubRepositoryApiError ;
9696 /** Let this many gh calls succeed before failWith kicks in (default 0 = fail immediately). */
9797 failAfterCalls ?: number ;
9898}
@@ -111,7 +111,9 @@ type FakeGitTextGeneration = TextGeneration.TextGeneration["Service"];
111111
112112type FakePullRequest = NonNullable < FakeGhScenario [ "pullRequest" ] > ;
113113
114- function normalizeFakePullRequestSummary ( raw : unknown ) : GitHubCli . GitHubPullRequestSummary | null {
114+ function normalizeFakePullRequestSummary (
115+ raw : unknown ,
116+ ) : GitHubRepositoryApi . GitHubPullRequestSummary | null {
115117 if ( ! raw || typeof raw !== "object" ) {
116118 return null ;
117119 }
@@ -381,8 +383,8 @@ function createTextGeneration(
381383 } ;
382384}
383385
384- function createGitHubCliWithFakeGh ( scenario : FakeGhScenario = { } ) : {
385- service : GitHubCli . GitHubCli [ "Service" ] ;
386+ function createGitHubRepositoryApiWithFakeGh ( scenario : FakeGhScenario = { } ) : {
387+ service : GitHubRepositoryApi . GitHubRepositoryApi [ "Service" ] ;
386388 ghCalls : string [ ] ;
387389} {
388390 const prListQueue = [ ...( scenario . prListSequence ?? [ ] ) ] ;
@@ -398,7 +400,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
398400 const execute = ( input : {
399401 readonly cwd : string ;
400402 readonly args : ReadonlyArray < string > ;
401- } ) : Effect . Effect < VcsProcess . VcsProcessOutput , GitHubCli . GitHubCliError > => {
403+ } ) : Effect . Effect < VcsProcess . VcsProcessOutput , GitHubRepositoryApi . GitHubRepositoryApiError > => {
402404 const args = [ ...input . args ] ;
403405 ghCalls . push ( args . join ( " " ) ) ;
404406
@@ -486,10 +488,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
486488 return fakeGhOutput ( "" ) ;
487489 } ,
488490 catch : ( error ) =>
489- GitHubCli . isGitHubCliError ( error )
491+ GitHubRepositoryApi . isGitHubRepositoryApiError ( error )
490492 ? error
491- : new GitHubCli . GitHubCliCommandError ( {
492- command : "gh" ,
493+ : new GitHubRepositoryApi . GitHubRepositoryCommandError ( {
493494 cwd : input . cwd ,
494495 cause : error ,
495496 } ) ,
@@ -502,8 +503,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
502503 const cloneUrls = scenario . repositoryCloneUrls ?. [ repository ] ;
503504 if ( ! cloneUrls ) {
504505 return Effect . fail (
505- new GitHubCli . GitHubCliCommandError ( {
506- command : "gh" ,
506+ new GitHubRepositoryApi . GitHubRepositoryCommandError ( {
507507 cwd : input . cwd ,
508508 cause : new Error ( `Unexpected repository lookup: ${ repository } ` ) ,
509509 } ) ,
@@ -523,8 +523,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
523523 }
524524
525525 return Effect . fail (
526- new GitHubCli . GitHubCliCommandError ( {
527- command : "gh" ,
526+ new GitHubRepositoryApi . GitHubRepositoryCommandError ( {
528527 cwd : input . cwd ,
529528 cause : new Error ( `Unexpected gh command: ${ args . join ( " " ) } ` ) ,
530529 } ) ,
@@ -577,7 +576,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
577576 Effect . map ( ( raw ) =>
578577 raw
579578 . map ( ( entry ) => normalizeFakePullRequestSummary ( entry ) )
580- . filter ( ( entry ) : entry is GitHubCli . GitHubPullRequestSummary => entry !== null ) ,
579+ . filter (
580+ ( entry ) : entry is GitHubRepositoryApi . GitHubPullRequestSummary => entry !== null ,
581+ ) ,
581582 ) ,
582583 ) ,
583584 createPullRequest : ( input ) =>
@@ -617,7 +618,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
617618 "number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,closedAt,isCrossRepository,headRepository,headRepositoryOwner" ,
618619 ] ,
619620 } ) . pipe (
620- Effect . map ( ( result ) => JSON . parse ( result . stdout ) as GitHubCli . GitHubPullRequestSummary ) ,
621+ Effect . map (
622+ ( result ) => JSON . parse ( result . stdout ) as GitHubRepositoryApi . GitHubPullRequestSummary ,
623+ ) ,
621624 ) ,
622625 getRepositoryCloneUrls : ( input ) =>
623626 execute ( {
@@ -626,8 +629,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
626629 } ) . pipe ( Effect . map ( ( result ) => JSON . parse ( result . stdout ) ) ) ,
627630 createRepository : ( input ) =>
628631 Effect . fail (
629- new GitHubCli . GitHubCliCommandError ( {
630- command : "gh" ,
632+ new GitHubRepositoryApi . GitHubRepositoryCommandError ( {
631633 cwd : input . cwd ,
632634 cause : new Error ( `Unexpected repository create: ${ input . repository } ` ) ,
633635 } ) ,
@@ -691,7 +693,9 @@ function makeManager(input?: {
691693 ProjectionStore . ProjectionStoreV2 | ProjectStore . ProjectStoreV2
692694 > ;
693695} ) {
694- const { service : gitHubCli , ghCalls } = createGitHubCliWithFakeGh ( input ?. ghScenario ) ;
696+ const { service : gitHubRepositoryApi , ghCalls } = createGitHubRepositoryApiWithFakeGh (
697+ input ?. ghScenario ,
698+ ) ;
695699 const textGeneration = createTextGeneration ( input ?. textGeneration ) ;
696700 const layerServerConfig = ServerConfig . layerTest ( process . cwd ( ) , {
697701 prefix : "t3-git-manager-test-" ,
@@ -740,7 +744,7 @@ function makeManager(input?: {
740744 ) ,
741745 Effect . provide (
742746 Layer . merge (
743- Layer . succeed ( GitHubCli . GitHubCli , gitHubCli ) ,
747+ Layer . succeed ( GitHubRepositoryApi . GitHubRepositoryApi , gitHubRepositoryApi ) ,
744748 Layer . mock ( GitHubApi . GitHubApi ) ( { } ) ,
745749 ) ,
746750 ) ,
@@ -1296,8 +1300,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
12961300 yield * runGit ( repoDir , [ "push" , "-u" , "origin" , "feature/rate-limited" ] ) ;
12971301 const { manager, ghCalls } = yield * makeManager ( {
12981302 ghScenario : {
1299- failWith : new GitHubCli . GitHubCliUnavailableError ( {
1300- command : "gh" ,
1303+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
13011304 cwd : repoDir ,
13021305 cause : new Error ( "rate limited" ) ,
13031306 } ) ,
@@ -1779,8 +1782,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
17791782
17801783 const { manager, ghCalls } = yield * makeManager ( {
17811784 ghScenario : {
1782- failWith : new GitHubCli . GitHubCliUnavailableError ( {
1783- command : "gh" ,
1785+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
17841786 cwd : repoDir ,
17851787 cause : new Error ( "gh is not available on PATH" ) ,
17861788 } ) ,
@@ -2640,8 +2642,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
26402642 } ,
26412643 ] ) ,
26422644 } ,
2643- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2644- command : "gh" ,
2645+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
26452646 cwd : repoDir ,
26462647 cause : new Error ( "rate limited" ) ,
26472648 } ) ,
@@ -2717,8 +2718,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
27172718
27182719 const { manager } = yield * makeManager ( {
27192720 ghScenario : {
2720- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2721- command : "gh" ,
2721+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
27222722 cwd : repoDir ,
27232723 cause : new Error ( "gh is not available on PATH" ) ,
27242724 } ) ,
@@ -2743,8 +2743,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
27432743 const upstreamCause = "GraphQL rate limit for user ID 51714798 and token secret-value" ;
27442744 const { manager } = yield * makeManager ( {
27452745 ghScenario : {
2746- failWith : new GitHubCli . GitHubCliRateLimitError ( {
2747- command : "gh" ,
2746+ failWith : new GitHubRepositoryApi . GitHubRepositoryRateLimitError ( {
27482747 cwd : repoDir ,
27492748 cause : new Error ( upstreamCause ) ,
27502749 } ) ,
@@ -2770,7 +2769,6 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
27702769 errorTag : "SourceControlProviderError" ,
27712770 provider : "github" ,
27722771 providerOperation : "listChangeRequests" ,
2773- providerCommand : "gh" ,
27742772 errorDetail : "GitHub API rate limit exceeded. Requests resume when the limit resets." ,
27752773 } ) ;
27762774 const loggedText = [
@@ -2801,8 +2799,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
28012799 const { manager } = yield * makeManager ( {
28022800 ghScenario : {
28032801 prListSequence : [ JSON . stringify ( [ existingPr ] ) ] ,
2804- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2805- command : "gh" ,
2802+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
28062803 cwd : repoDir ,
28072804 cause : new Error ( "rate limited" ) ,
28082805 } ) ,
@@ -2844,8 +2841,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
28442841 const { manager } = yield * makeManager ( {
28452842 ghScenario : {
28462843 prListSequence : [ JSON . stringify ( [ existingPr ] ) ] ,
2847- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2848- command : "gh" ,
2844+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
28492845 cwd : repoDir ,
28502846 cause : new Error ( "rate limited" ) ,
28512847 } ) ,
@@ -2892,8 +2888,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
28922888 const { manager } = yield * makeManager ( {
28932889 ghScenario : {
28942890 prListSequence : [ JSON . stringify ( [ existingPr ] ) ] ,
2895- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2896- command : "gh" ,
2891+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
28972892 cwd : repoDir ,
28982893 cause : new Error ( "rate limited" ) ,
28992894 } ) ,
@@ -2931,8 +2926,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
29312926 const { manager } = yield * makeManager ( {
29322927 ghScenario : {
29332928 prListSequence : [ JSON . stringify ( [ existingPr ] ) ] ,
2934- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2935- command : "gh" ,
2929+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
29362930 cwd : repoDir ,
29372931 cause : new Error ( "rate limited" ) ,
29382932 } ) ,
@@ -2973,8 +2967,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
29732967 const { manager } = yield * makeManager ( {
29742968 ghScenario : {
29752969 prListSequence : [ JSON . stringify ( [ existingPr ] ) ] ,
2976- failWith : new GitHubCli . GitHubCliUnavailableError ( {
2977- command : "gh" ,
2970+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
29782971 cwd : repoDir ,
29792972 cause : new Error ( "rate limited" ) ,
29802973 } ) ,
@@ -4618,8 +4611,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
46184611
46194612 const { manager } = yield * makeManager ( {
46204613 ghScenario : {
4621- failWith : new GitHubCli . GitHubCliUnavailableError ( {
4622- command : "gh" ,
4614+ failWith : new GitHubRepositoryApi . GitHubRepositoryUnavailableError ( {
46234615 cwd : repoDir ,
46244616 cause : new Error ( "gh is not available on PATH" ) ,
46254617 } ) ,
@@ -4648,8 +4640,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
46484640
46494641 const { manager } = yield * makeManager ( {
46504642 ghScenario : {
4651- failWith : new GitHubCli . GitHubCliAuthenticationError ( {
4652- command : "gh" ,
4643+ failWith : new GitHubRepositoryApi . GitHubRepositoryAuthenticationError ( {
46534644 cwd : repoDir ,
46544645 cause : new Error ( "gh is not authenticated" ) ,
46554646 } ) ,
0 commit comments