@@ -8,6 +8,18 @@ namespace SourceGit.ViewModels
88{
99 public class ScanRepositories : Popup
1010 {
11+ public bool UseCustomDir
12+ {
13+ get => _useCustomDir ;
14+ set => SetProperty ( ref _useCustomDir , value ) ;
15+ }
16+
17+ public string CustomDir
18+ {
19+ get => _customDir ;
20+ set => SetProperty ( ref _customDir , value ) ;
21+ }
22+
1123 public List < Models . ScanDir > ScanDirs
1224 {
1325 get ;
@@ -33,16 +45,28 @@ public ScanRepositories()
3345
3446 if ( ScanDirs . Count > 0 )
3547 _selected = ScanDirs [ 0 ] ;
48+ else
49+ _useCustomDir = true ;
3650
3751 GetManagedRepositories ( Preferences . Instance . RepositoryNodes , _managed ) ;
3852 }
3953
4054 public override async Task < bool > Sure ( )
4155 {
42- ProgressDescription = $ "Scan repositories under '{ _selected . Path } ' ...";
56+ var selectedDir = _useCustomDir ? _customDir : _selected ? . Path ;
57+ if ( string . IsNullOrEmpty ( selectedDir ) )
58+ {
59+ App . RaiseException ( null , "Missing root directory to scan!" ) ;
60+ return false ;
61+ }
62+
63+ if ( ! Directory . Exists ( selectedDir ) )
64+ return true ;
65+
66+ ProgressDescription = $ "Scan repositories under '{ selectedDir } ' ...";
4367
4468 var minDelay = Task . Delay ( 500 ) ;
45- var rootDir = new DirectoryInfo ( _selected . Path ) ;
69+ var rootDir = new DirectoryInfo ( selectedDir ) ;
4670 var found = new List < string > ( ) ;
4771
4872 await GetUnmanagedRepositoriesAsync ( rootDir , found , new EnumerationOptions ( )
@@ -162,6 +186,8 @@ private RepositoryNode FindOrCreateGroup(List<RepositoryNode> collection, string
162186 }
163187
164188 private HashSet < string > _managed = new ( ) ;
189+ private bool _useCustomDir = false ;
190+ private string _customDir = string . Empty ;
165191 private Models . ScanDir _selected = null ;
166192 }
167193}
0 commit comments