@@ -8,6 +8,18 @@ namespace SourceGit.ViewModels
8
8
{
9
9
public class ScanRepositories : Popup
10
10
{
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
+
11
23
public List < Models . ScanDir > ScanDirs
12
24
{
13
25
get ;
@@ -33,16 +45,28 @@ public ScanRepositories()
33
45
34
46
if ( ScanDirs . Count > 0 )
35
47
_selected = ScanDirs [ 0 ] ;
48
+ else
49
+ _useCustomDir = true ;
36
50
37
51
GetManagedRepositories ( Preferences . Instance . RepositoryNodes , _managed ) ;
38
52
}
39
53
40
54
public override async Task < bool > Sure ( )
41
55
{
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 } ' ...";
43
67
44
68
var minDelay = Task . Delay ( 500 ) ;
45
- var rootDir = new DirectoryInfo ( _selected . Path ) ;
69
+ var rootDir = new DirectoryInfo ( selectedDir ) ;
46
70
var found = new List < string > ( ) ;
47
71
48
72
await GetUnmanagedRepositoriesAsync ( rootDir , found , new EnumerationOptions ( )
@@ -162,6 +186,8 @@ private RepositoryNode FindOrCreateGroup(List<RepositoryNode> collection, string
162
186
}
163
187
164
188
private HashSet < string > _managed = new ( ) ;
189
+ private bool _useCustomDir = false ;
190
+ private string _customDir = string . Empty ;
165
191
private Models . ScanDir _selected = null ;
166
192
}
167
193
}
0 commit comments