@@ -35,11 +35,7 @@ import { CommitSaga } from "@posthog/git/sagas/commit";
3535import { DiscardFileChangesSaga } from "@posthog/git/sagas/discard" ;
3636import { PullSaga } from "@posthog/git/sagas/pull" ;
3737import { PushSaga } from "@posthog/git/sagas/push" ;
38- import {
39- parseGitHubUrl ,
40- parseGithubRefUrl ,
41- parsePrUrl ,
42- } from "@posthog/git/utils" ;
38+ import { parseGithubUrl } from "@posthog/git/utils" ;
4339import { inject , injectable } from "inversify" ;
4440import { MAIN_TOKENS } from "../../di/tokens" ;
4541import { logger } from "../../utils/logger" ;
@@ -222,15 +218,15 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
222218 const remoteUrl = await getRemoteUrl ( directoryPath ) ;
223219 if ( ! remoteUrl ) return null ;
224220
225- const repo = parseGitHubUrl ( remoteUrl ) ;
226- if ( ! repo ) return null ;
221+ const parsed = parseGithubUrl ( remoteUrl ) ;
222+ if ( ! parsed ) return null ;
227223
228224 const branch = await getCurrentBranch ( directoryPath ) ;
229225 if ( ! branch ) return null ;
230226
231227 return {
232- organization : repo . organization ,
233- repository : repo . repository ,
228+ organization : parsed . owner ,
229+ repository : parsed . repo ,
234230 remote : remoteUrl ,
235231 branch,
236232 } ;
@@ -430,20 +426,20 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
430426 const remoteUrl = await getRemoteUrl ( directoryPath ) ;
431427 if ( ! remoteUrl ) return null ;
432428
433- const parsed = parseGitHubUrl ( remoteUrl ) ;
429+ const parsed = parseGithubUrl ( remoteUrl ) ;
434430 if ( ! parsed ) return null ;
435431
436432 const currentBranch = await getCurrentBranch ( directoryPath ) ;
437433 const defaultBranch = await getDefaultBranch ( directoryPath ) ;
438434
439435 let compareUrl : string | null = null ;
440436 if ( currentBranch && currentBranch !== defaultBranch ) {
441- compareUrl = `https://github.com/${ parsed . path } /compare/${ defaultBranch } ...${ currentBranch } ?expand=1` ;
437+ compareUrl = `https://github.com/${ parsed . owner } / ${ parsed . repo } /compare/${ defaultBranch } ...${ currentBranch } ?expand=1` ;
442438 }
443439
444440 return {
445- organization : parsed . organization ,
446- repository : parsed . repository ,
441+ organization : parsed . owner ,
442+ repository : parsed . repo ,
447443 currentBranch : currentBranch ?? null ,
448444 defaultBranch,
449445 compareUrl,
@@ -823,7 +819,7 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
823819
824820 try {
825821 const remoteUrl = await getRemoteUrl ( directoryPath ) ;
826- const isGitHubRepo = ! ! ( remoteUrl && parseGitHubUrl ( remoteUrl ) ) ;
822+ const isGitHubRepo = ! ! ( remoteUrl && parseGithubUrl ( remoteUrl ) ) ;
827823 const currentBranch = await getCurrentBranch ( directoryPath ) ;
828824 const defaultBranch = await getDefaultBranch ( directoryPath ) . catch (
829825 ( ) => null ,
@@ -894,7 +890,7 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
894890 const remoteUrl = await getRemoteUrl ( directoryPath ) ;
895891 if ( ! remoteUrl ) return null ;
896892
897- const parsed = parseGitHubUrl ( remoteUrl ) ;
893+ const parsed = parseGithubUrl ( remoteUrl ) ;
898894 if ( ! parsed ) return null ;
899895
900896 const result = await execGh ( [
@@ -909,7 +905,7 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
909905 "--limit" ,
910906 "1" ,
911907 "--repo" ,
912- parsed . path ,
908+ ` ${ parsed . owner } / ${ parsed . repo } ` ,
913909 ] ) ;
914910
915911 if ( result . exitCode !== 0 ) {
@@ -984,8 +980,8 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
984980 }
985981
986982 public async getPrChangedFiles ( prUrl : string ) : Promise < ChangedFile [ ] > {
987- const pr = parsePrUrl ( prUrl ) ;
988- if ( ! pr ) return [ ] ;
983+ const pr = parseGithubUrl ( prUrl ) ;
984+ if ( pr ?. kind !== "pr" ) return [ ] ;
989985
990986 const { owner, repo, number } = pr ;
991987
@@ -1057,8 +1053,8 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
10571053 public async getPrDetailsByUrl (
10581054 prUrl : string ,
10591055 ) : Promise < PrDetailsByUrlOutput | null > {
1060- const pr = parsePrUrl ( prUrl ) ;
1061- if ( ! pr ) return null ;
1056+ const pr = parseGithubUrl ( prUrl ) ;
1057+ if ( pr ?. kind !== "pr" ) return null ;
10621058
10631059 try {
10641060 const result = await execGh ( [
@@ -1093,8 +1089,8 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
10931089 prUrl : string ,
10941090 action : PrActionType ,
10951091 ) : Promise < UpdatePrByUrlOutput > {
1096- const pr = parsePrUrl ( prUrl ) ;
1097- if ( ! pr ) {
1092+ const pr = parseGithubUrl ( prUrl ) ;
1093+ if ( pr ?. kind !== "pr" ) {
10981094 return { success : false , message : "Invalid PR URL" } ;
10991095 }
11001096
@@ -1127,8 +1123,8 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
11271123 }
11281124
11291125 public async getPrReviewComments ( prUrl : string ) : Promise < PrReviewComment [ ] > {
1130- const pr = parsePrUrl ( prUrl ) ;
1131- if ( ! pr ) return [ ] ;
1126+ const pr = parseGithubUrl ( prUrl ) ;
1127+ if ( pr ?. kind !== "pr" ) return [ ] ;
11321128
11331129 const { owner, repo, number } = pr ;
11341130
@@ -1159,8 +1155,8 @@ export class GitService extends TypedEventEmitter<GitServiceEvents> {
11591155 commentId : number ,
11601156 body : string ,
11611157 ) : Promise < ReplyToPrCommentOutput > {
1162- const pr = parsePrUrl ( prUrl ) ;
1163- if ( ! pr ) {
1158+ const pr = parseGithubUrl ( prUrl ) ;
1159+ if ( pr ?. kind !== "pr" ) {
11641160 return { success : false , comment : null } ;
11651161 }
11661162
@@ -1549,8 +1545,8 @@ ${truncatedDiff || "(no diff available)"}${contextSection}`;
15491545 if ( ! repoInfo ) return [ ] ;
15501546
15511547 // Full GitHub URL: look up directly. May target a different repo than the local one.
1552- const urlRef = parseGithubRefUrl ( query ) ;
1553- if ( urlRef && kinds . includes ( urlRef . kind ) ) {
1548+ const urlRef = parseGithubUrl ( query ) ;
1549+ if ( urlRef && urlRef . kind !== "repo" && kinds . includes ( urlRef . kind ) ) {
15541550 const repoSlug = `${ urlRef . owner } /${ urlRef . repo } ` ;
15551551 return this . fetchGhRefs (
15561552 [
0 commit comments