@@ -11,15 +11,25 @@ public IssueTracker(string repo, string storage)
11
11
{
12
12
WorkingDirectory = repo ;
13
13
Context = repo ;
14
- _storage = storage ;
14
+
15
+ if ( string . IsNullOrEmpty ( storage ) )
16
+ {
17
+ _isStorageFileExists = true ;
18
+ _baseArg = "config --local" ;
19
+ }
20
+ else
21
+ {
22
+ _isStorageFileExists = File . Exists ( storage ) ;
23
+ _baseArg = $ "config -f { storage . Quoted ( ) } ";
24
+ }
15
25
}
16
26
17
27
public async Task ReadAllAsync ( List < Models . IssueTracker > outs , bool isShared )
18
28
{
19
- if ( ! File . Exists ( _storage ) )
29
+ if ( ! _isStorageFileExists )
20
30
return ;
21
31
22
- Args = $ "config -f { _storage . Quoted ( ) } -l";
32
+ Args = $ "{ _baseArg } -l";
23
33
24
34
var rs = await ReadToEndAsync ( ) . ConfigureAwait ( false ) ;
25
35
if ( rs . IsSuccess )
@@ -57,12 +67,12 @@ public async Task ReadAllAsync(List<Models.IssueTracker> outs, bool isShared)
57
67
58
68
public async Task < bool > AddAsync ( Models . IssueTracker rule )
59
69
{
60
- Args = $ "config -f { _storage . Quoted ( ) } issuetracker.{ rule . Name . Quoted ( ) } .regex { rule . RegexString . Quoted ( ) } ";
70
+ Args = $ "{ _baseArg } issuetracker.{ rule . Name . Quoted ( ) } .regex { rule . RegexString . Quoted ( ) } ";
61
71
62
72
var succ = await ExecAsync ( ) . ConfigureAwait ( false ) ;
63
73
if ( succ )
64
74
{
65
- Args = $ "config -f { _storage . Quoted ( ) } issuetracker.{ rule . Name . Quoted ( ) } .url { rule . URLTemplate . Quoted ( ) } ";
75
+ Args = $ "{ _baseArg } issuetracker.{ rule . Name . Quoted ( ) } .url { rule . URLTemplate . Quoted ( ) } ";
66
76
return await ExecAsync ( ) . ConfigureAwait ( false ) ;
67
77
}
68
78
@@ -71,10 +81,10 @@ public async Task<bool> AddAsync(Models.IssueTracker rule)
71
81
72
82
public async Task < bool > RemoveAsync ( Models . IssueTracker rule )
73
83
{
74
- if ( ! File . Exists ( _storage ) )
84
+ if ( ! _isStorageFileExists )
75
85
return true ;
76
86
77
- Args = $ "config -f { _storage . Quoted ( ) } --remove-section issuetracker.{ rule . Name . Quoted ( ) } ";
87
+ Args = $ "{ _baseArg } --remove-section issuetracker.{ rule . Name . Quoted ( ) } ";
78
88
return await ExecAsync ( ) . ConfigureAwait ( false ) ;
79
89
}
80
90
@@ -89,6 +99,7 @@ private Models.IssueTracker FindOrAdd(List<Models.IssueTracker> rules, string ru
89
99
return rule ;
90
100
}
91
101
92
- private readonly string _storage ;
102
+ private readonly bool _isStorageFileExists ;
103
+ private readonly string _baseArg ;
93
104
}
94
105
}
0 commit comments