File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
CodeEdit/Features/SourceControl/Clone/ViewModels Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,22 @@ class GitCloneViewModel: ObservableObject {
3131 }
3232 return false
3333 }
34+ /// Check if Git is installed
35+ /// - Returns: True if Git is found by running "which git" command
36+ func isGitInstalled( ) -> Bool {
37+ let process = Process ( )
38+ process. executableURL = URL ( fileURLWithPath: " /usr/bin/which " )
39+ process. arguments = [ " git " ]
40+ let pipe = Pipe ( )
41+ process. standardOutput = pipe
42+ do {
43+ try process. run ( )
44+ process. waitUntilExit ( )
45+ return process. terminationStatus == 0
46+ } catch {
47+ return false
48+ }
49+ }
3450
3551 /// Check if clipboard contains git url
3652 func checkClipboard( ) {
@@ -43,6 +59,13 @@ class GitCloneViewModel: ObservableObject {
4359
4460 /// Clone repository
4561 func cloneRepository( completionHandler: @escaping ( URL ) -> Void ) {
62+ if !isGitInstalled( ) {
63+ showAlert (
64+ alertMsg: " Git installation not found. " ,
65+ infoText: " Ensure Git is installed on your system and try again. "
66+ )
67+ return
68+ }
4669 if repoUrlStr == " " {
4770 showAlert (
4871 alertMsg: " Url cannot be empty " ,
You can’t perform that action at this time.
0 commit comments