@@ -6,6 +6,7 @@ import { promisify } from "node:util";
66import type { ChangedFile , GitFileStatus } from "@shared/types" ;
77import { type IpcMainInvokeEvent , ipcMain } from "electron" ;
88import { logger } from "../lib/logger" ;
9+ import { parseGitHubUrl } from "./git/utils" ;
910
1011const log = logger . scope ( "git" ) ;
1112
@@ -51,24 +52,6 @@ const getAllFilesInDirectory = async (
5152 return files ;
5253} ;
5354
54- export interface GitHubRepo {
55- organization : string ;
56- repository : string ;
57- }
58-
59- export const parseGitHubUrl = ( url : string ) : GitHubRepo | null => {
60- const match =
61- url . match ( / g i t h u b \. c o m [: / ] ( .+ ?) \/ ( .+ ?) ( \. g i t ) ? $ / ) ||
62- url . match ( / g i t @ g i t h u b \. c o m : ( .+ ?) \/ ( .+ ?) ( \. g i t ) ? $ / ) ;
63-
64- if ( ! match ) return null ;
65-
66- return {
67- organization : match [ 1 ] ,
68- repository : match [ 2 ] . replace ( / \. g i t $ / , "" ) ,
69- } ;
70- } ;
71-
7255export const isGitRepository = async (
7356 directoryPath : string ,
7457) : Promise < boolean > => {
@@ -690,31 +673,6 @@ export function registerGitIpc(): void {
690673 } ,
691674 ) ;
692675
693- ipcMain . handle (
694- "detect-repo" ,
695- async (
696- _event : IpcMainInvokeEvent ,
697- directoryPath : string ,
698- ) : Promise < {
699- organization : string ;
700- repository : string ;
701- branch ?: string ;
702- remote ?: string ;
703- } | null > => {
704- if ( ! directoryPath ) return null ;
705-
706- const remoteUrl = await getRemoteUrl ( directoryPath ) ;
707- if ( ! remoteUrl ) return null ;
708-
709- const repo = parseGitHubUrl ( remoteUrl ) ;
710- if ( ! repo ) return null ;
711-
712- const branch = await getCurrentBranch ( directoryPath ) ;
713-
714- return { ...repo , branch, remote : remoteUrl } ;
715- } ,
716- ) ;
717-
718676 ipcMain . handle (
719677 "get-changed-files-head" ,
720678 async (
0 commit comments