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)
5858 return rs ;
5959 }
6060
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+
6185 public async Task < bool > AddAsync ( Models . IssueTrackerRule rule )
6286 {
6387 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()
314314 {
315315 await sharedTracker . RemoveAsync ( rule ) ;
316316
317- if ( ( await sharedTracker . ReadAllAsync ( ) ) . Count != 0 )
317+ if ( await sharedTracker . HasAnyAsync ( ) )
318318 return ;
319-
319+
320320 var filePath = Path . Combine ( _repo . FullPath , ".issuetracker" ) ;
321321
322- if ( ! string . IsNullOrEmpty ( await File . ReadAllTextAsync ( filePath ) ) )
322+ if ( ! File . Exists ( filePath ) || ! string . IsNullOrEmpty ( await File . ReadAllTextAsync ( filePath ) ) )
323323 return ;
324-
325- if ( File . Exists ( filePath ) )
326- File . Delete ( filePath ) ;
324+
325+ File . Delete ( filePath ) ;
327326 }
328327 }
329328
You can’t perform that action at this time.
0 commit comments