@@ -40,6 +40,10 @@ type GitHubCliPrResponse = {
4040export class GitHubProvider extends GitProvider {
4141 readonly name = "github" as const ;
4242
43+ private get apiPath ( ) : string {
44+ return `repos/${ encodeURIComponent ( this . owner ) } /${ encodeURIComponent ( this . repo ) } ` ;
45+ }
46+
4347 async ensureAvailable ( ) : Promise < void > {
4448 try {
4549 await Bun . $ `which gh` . quiet ( ) ;
@@ -83,14 +87,14 @@ export class GitHubProvider extends GitProvider {
8387
8488 async createPr ( options : CreatePrOptions ) : Promise < PullRequest > {
8589 const result =
86- await Bun . $ `gh api repos/ ${ this . owner } / ${ this . repo } /pulls --method POST -f head=${ options . head } -f base=${ options . base } -f title=${ options . title } -f body=${ options . body } ` ;
90+ await Bun . $ `gh api ${ this . apiPath } /pulls --method POST -f head=${ options . head } -f base=${ options . base } -f title=${ options . title } -f body=${ options . body } ` ;
8791
8892 const data = JSON . parse ( result . stdout . toString ( ) ) ;
8993 const prNumber = data . number as number ;
9094
9195 if ( options . labels && options . labels . length > 0 ) {
9296 const labelArgs = options . labels . flatMap ( ( l ) => [ "-f" , `labels[]=${ l } ` ] ) ;
93- await Bun . $ `gh api repos/ ${ this . owner } / ${ this . repo } /issues/${ prNumber } /labels --method POST ${ labelArgs } ` ;
97+ await Bun . $ `gh api ${ this . apiPath } /issues/${ prNumber } /labels --method POST ${ labelArgs } ` ;
9498 }
9599
96100 return this . getPr ( prNumber ) ;
@@ -106,7 +110,7 @@ export class GitHubProvider extends GitProvider {
106110
107111 async getPr ( number : number ) : Promise < PullRequest > {
108112 try {
109- const result = await Bun . $ `gh api repos/ ${ this . owner } / ${ this . repo } /pulls/${ number } ` . quiet ( ) ;
113+ const result = await Bun . $ `gh api ${ this . apiPath } /pulls/${ number } ` . quiet ( ) ;
110114 const data = JSON . parse ( result . stdout . toString ( ) ) ;
111115
112116 return this . mapRestApiResponse ( data ) ;
@@ -130,7 +134,7 @@ export class GitHubProvider extends GitProvider {
130134 async getPrCommits ( number : number ) : Promise < string [ ] > {
131135 try {
132136 const result =
133- await Bun . $ `gh api repos/ ${ this . owner } / ${ this . repo } /pulls/${ number } /commits --jq '.[].sha'` . quiet ( ) ;
137+ await Bun . $ `gh api ${ this . apiPath } /pulls/${ number } /commits --jq '.[].sha'` . quiet ( ) ;
134138 return result . stdout . toString ( ) . trim ( ) . split ( "\n" ) . filter ( Boolean ) ;
135139 } catch {
136140 return [ ] ;
@@ -140,7 +144,7 @@ export class GitHubProvider extends GitProvider {
140144 async getPrFiles ( number : number ) : Promise < string [ ] > {
141145 try {
142146 const result =
143- await Bun . $ `gh api repos/ ${ this . owner } / ${ this . repo } /pulls/${ number } /files --jq '.[].filename'` . quiet ( ) ;
147+ await Bun . $ `gh api ${ this . apiPath } /pulls/${ number } /files --jq '.[].filename'` . quiet ( ) ;
144148 return result . stdout . toString ( ) . trim ( ) . split ( "\n" ) . filter ( Boolean ) ;
145149 } catch {
146150 return [ ] ;
0 commit comments