File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed
Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ private static async Task<int> Main(string[] args)
7171 var minimumInteractionIntervalOption = new Option < int > (
7272 name : "--minimum-interaction-interval" ,
7373 description : "Minimum interaction interval in seconds." ,
74- getDefaultValue : ( ) => 60 ) ;
74+ getDefaultValue : ( ) => 300 ) ;
7575
7676 var rootCommand = new RootCommand ( "Sample app for System.CommandLine" )
7777 {
Original file line number Diff line number Diff line change @@ -31,6 +31,14 @@ public class IssueTracker : ITracker<Issue>
3131 /// </summary>
3232 private IList < ITrigger < Issue > > _triggers { get ; }
3333
34+ /// <summary>
35+ /// <para>
36+ /// Tracks processed issues to prevent duplicate actions.
37+ /// </para>
38+ /// <para></para>
39+ /// </summary>
40+ private HashSet < string > _processedIssues { get ; } = new HashSet < string > ( ) ;
41+
3442 /// <summary>
3543 /// <para>
3644 /// Initializes a new <see cref="IssueTracker"/> instance.
@@ -66,6 +74,15 @@ public async Task Start(CancellationToken cancellationToken)
6674 var allIssues = _storage . GetIssues ( ) ;
6775 foreach ( var issue in allIssues )
6876 {
77+ // Create a unique key for each issue-trigger combination to prevent duplicate processing
78+ var issueKey = $ "{ issue . Repository . FullName } #{ issue . Number } ";
79+
80+ // Skip if this issue has already been processed
81+ if ( _processedIssues . Contains ( issueKey ) )
82+ {
83+ continue ;
84+ }
85+
6986 foreach ( var trigger in _triggers )
7087 {
7188 if ( cancellationToken . IsCancellationRequested )
@@ -75,6 +92,9 @@ public async Task Start(CancellationToken cancellationToken)
7592 if ( await trigger . Condition ( issue ) )
7693 {
7794 await trigger . Action ( issue ) ;
95+ // Mark issue as processed after successful action
96+ _processedIssues . Add ( issueKey ) ;
97+ break ; // Only process one trigger per issue to prevent conflicts
7898 }
7999 }
80100 }
Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ public class PullRequestTracker : ITracker<PullRequest>
3333 /// </summary>
3434 private IList < ITrigger < PullRequest > > _triggers ;
3535
36+ /// <summary>
37+ /// <para>
38+ /// Tracks processed pull requests to prevent duplicate actions.
39+ /// </para>
40+ /// <para></para>
41+ /// </summary>
42+ private HashSet < string > _processedPullRequests = new HashSet < string > ( ) ;
43+
3644 /// <summary>
3745 /// <para>
3846 /// Initializes a new <see cref="IssueTracker"/> instance.
@@ -75,10 +83,22 @@ public async Task Start(CancellationToken cancellationToken)
7583 {
7684 return ;
7785 }
86+
87+ // Create a unique key for each pull request to prevent duplicate processing
88+ var pullRequestKey = $ "{ repository . FullName } #{ pullRequest . Number } ";
89+
90+ // Skip if this pull request has already been processed
91+ if ( _processedPullRequests . Contains ( pullRequestKey ) )
92+ {
93+ continue ;
94+ }
95+
7896 var detailedPullRequest = _storage . Client . PullRequest . Get ( repository . Id , pullRequest . Number ) . AwaitResult ( ) ;
7997 if ( await trigger . Condition ( detailedPullRequest ) )
8098 {
8199 await trigger . Action ( detailedPullRequest ) ;
100+ // Mark pull request as processed after successful action
101+ _processedPullRequests . Add ( pullRequestKey ) ;
82102 }
83103 }
84104 }
You can’t perform that action at this time.
0 commit comments