File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,30 @@ public SharedIssueTracker(string repo)
58
58
return rs ;
59
59
}
60
60
61
+ public async Task < bool > HasAnyAsync ( )
62
+ {
63
+ if ( ! File . Exists ( _file ) )
64
+ return false ;
65
+
66
+ Args = $ "config -f { _file . Quoted ( ) } -l";
67
+
68
+ var output = await ReadToEndAsync ( ) . ConfigureAwait ( false ) ;
69
+
70
+ if ( output . IsSuccess )
71
+ foreach ( var line in output . StdOut . Split ( [ '\r ' , '\n ' ] , StringSplitOptions . RemoveEmptyEntries ) )
72
+ {
73
+ var parts = line . Split ( '=' , 2 ) ;
74
+
75
+ if ( parts . Length < 2 )
76
+ continue ;
77
+
78
+ if ( parts [ 0 ] . StartsWith ( "issuetracker." , StringComparison . Ordinal ) )
79
+ return true ;
80
+ }
81
+
82
+ return false ;
83
+ }
84
+
61
85
public async Task < bool > AddAsync ( Models . IssueTrackerRule rule )
62
86
{
63
87
Args = $ "config -f { _file . Quoted ( ) } issuetracker.{ rule . Name . Quoted ( ) } .regex { rule . RegexString . Quoted ( ) } ";
Original file line number Diff line number Diff line change @@ -314,16 +314,15 @@ public async Task ChangeIssueTrackerShareModeAsync()
314
314
{
315
315
await sharedTracker . RemoveAsync ( rule ) ;
316
316
317
- if ( ( await sharedTracker . ReadAllAsync ( ) ) . Count != 0 )
317
+ if ( await sharedTracker . HasAnyAsync ( ) )
318
318
return ;
319
-
319
+
320
320
var filePath = Path . Combine ( _repo . FullPath , ".issuetracker" ) ;
321
321
322
- if ( ! string . IsNullOrEmpty ( await File . ReadAllTextAsync ( filePath ) ) )
322
+ if ( ! File . Exists ( filePath ) || ! string . IsNullOrEmpty ( await File . ReadAllTextAsync ( filePath ) ) )
323
323
return ;
324
-
325
- if ( File . Exists ( filePath ) )
326
- File . Delete ( filePath ) ;
324
+
325
+ File . Delete ( filePath ) ;
327
326
}
328
327
}
329
328
You can’t perform that action at this time.
0 commit comments