@@ -373,6 +373,72 @@ public void OpenRepositoryInTab(RepositoryNode node, LauncherPage page)
373373 ActivePage = page ;
374374 }
375375
376+ public void OpenSubRepository ( LauncherPage ownerPage , string fullpath )
377+ {
378+ var normalizedPath = fullpath . Replace ( '\\ ' , '/' ) . TrimEnd ( '/' ) ;
379+
380+ // Check if the sub-repository is already open in any of the tabs
381+ foreach ( var one in Pages )
382+ {
383+ if ( one . Node . Id . Equals ( normalizedPath , StringComparison . Ordinal ) )
384+ {
385+ ActivePage = one ;
386+ return ;
387+ }
388+ }
389+
390+ // Make sure the target directory exists
391+ if ( ! Directory . Exists ( normalizedPath ) )
392+ {
393+ ownerPage . Notifications . Add ( new Models . Notification
394+ {
395+ Group = ownerPage . Node . Id ,
396+ Message = "Repository path does NOT exist. Please check the path." ,
397+ IsError = true ,
398+ } ) ;
399+
400+ return ;
401+ }
402+
403+ // Check if the target directory is a valid git repository
404+ var gitDir = GetRepositoryGitDir ( normalizedPath ) ;
405+ if ( string . IsNullOrEmpty ( gitDir ) )
406+ {
407+ ownerPage . Notifications . Add ( new Models . Notification
408+ {
409+ Group = ownerPage . Node . Id ,
410+ Message = "Given path is not a valid git repository!" ,
411+ IsError = true ,
412+ } ) ;
413+ return ;
414+ }
415+
416+ // Get the owner repository's name and extract the pure owner name (without any prefix)
417+ var ownerName = ownerPage . Node . Name ;
418+ var colonIdx = ownerName . LastIndexOf ( ':' ) ;
419+ var pureOwnerName = ( colonIdx >= 0 && colonIdx < ownerName . Length - 1 ) ? ownerName . Substring ( colonIdx + 1 ) . Trim ( ) : ownerName ;
420+
421+ // Find the sub-repository node in the preferences or create a new one if it doesn't exist
422+ var node = Preferences . Instance . FindNode ( normalizedPath ) ?? new RepositoryNode
423+ {
424+ Id = normalizedPath ,
425+ Name = $ "{ pureOwnerName } : { Path . GetFileName ( normalizedPath ) } ",
426+ Bookmark = 0 ,
427+ IsRepository = true ,
428+ IsUnmanaged = true
429+ } ;
430+ node . LoadMinimalInfo ( gitDir ) ;
431+
432+ var repo = new Repository ( false , node . Id , gitDir ) ;
433+ repo . Open ( ) ;
434+
435+ var page = new LauncherPage ( node , repo ) ;
436+ var idxOfOwner = Pages . IndexOf ( ownerPage ) ;
437+ Pages . Insert ( idxOfOwner + 1 , page ) ;
438+ _activeWorkspace . Repositories . Insert ( idxOfOwner + 1 , normalizedPath ) ;
439+ ActivePage = page ;
440+ }
441+
376442 private void DispatchNotification ( Models . Notification notification )
377443 {
378444 if ( ! Dispatcher . UIThread . CheckAccess ( ) )
0 commit comments