@@ -80,33 +80,38 @@ public PullRequestDetails AddDataToPullRequest(PullRequestDetails fromPullReques
8080 {
8181 string file = fromPullRequest . Files . FirstOrDefault ( ) . Name ;
8282 string number = fromPullRequest . PullRequest . ToString ( ) ;
83- Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
83+ // Stopwatch stopwatch = Stopwatch.StartNew();
8484
8585 var pr = new PullRequestDetails ( ) ;
8686
8787 // Find the pull request. Should always exist if OpenPullRequest has been called.
88- pr = PullRequests . FirstOrDefault ( pr => pr . PullRequest == fromPullRequest . PullRequest && pr . Commit == fromPullRequest . Commit ) ;
88+ pr = PullRequests . FirstOrDefault ( pr => pr . PullRequest == fromPullRequest . PullRequest ) ;
8989 if ( pr == null )
9090 throw new Exception ( $ "Cannot find POStats pull request number: { fromPullRequest . PullRequest } ") ;
91+ if ( pr . Commit != fromPullRequest . Commit )
92+ throw new Exception ( $ "PR { fromPullRequest . PullRequest } :{ fromPullRequest . Commit } is not the latest commit { pr . Commit } , cannot save stats.") ;
9193
92- stopwatch . Stop ( ) ;
93- Console . WriteLine ( $ "\" { file } \" found PR { number } in { stopwatch . ElapsedMilliseconds } ms") ;
94+ // stopwatch.Stop();
95+ // Console.WriteLine($"\"{file}\" found PR {number} in {stopwatch.ElapsedMilliseconds} ms");
9496
95- stopwatch = Stopwatch . StartNew ( ) ;
97+ // stopwatch = Stopwatch.StartNew();
9698 if ( fromPullRequest . Files != null )
9799 pr . Files . AddRange ( fromPullRequest . Files ) ;
98100
99101 if ( fromPullRequest . Outputs != null )
100102 pr . Outputs . AddRange ( fromPullRequest . Outputs ) ;
101103
102- stopwatch . Stop ( ) ;
103- Console . WriteLine ( $ " \" { file } \" copied to PR { number } in { stopwatch . ElapsedMilliseconds } ms" ) ;
104+ if ( fromPullRequest . Status != null )
105+ pr . Status . AddRange ( fromPullRequest . Status ) ;
104106
105- stopwatch = Stopwatch . StartNew ( ) ;
107+ //stopwatch.Stop();
108+ //Console.WriteLine($"\"{file}\" copied to PR {number} in {stopwatch.ElapsedMilliseconds} ms");
109+
110+ //stopwatch = Stopwatch.StartNew();
106111 SaveChanges ( ) ;
107112
108- stopwatch . Stop ( ) ;
109- Console . WriteLine ( $ "\" { file } \" written to PR { number } in { stopwatch . ElapsedMilliseconds } ms") ;
113+ // stopwatch.Stop();
114+ // Console.WriteLine($"\"{file}\" written to PR {number} in {stopwatch.ElapsedMilliseconds} ms");
110115
111116 return pr ;
112117 }
@@ -207,11 +212,13 @@ public int GetNumberOfCompletesInPullRequest(int pullrequestnumber, string commi
207212 var pr = new PullRequestDetails ( ) ;
208213
209214 // Find the pull request. Should always exist if OpenPullRequest has been called.
210- pr = PullRequests . FirstOrDefault ( pr => pr . PullRequest == pullrequestnumber && pr . Commit == commitid ) ;
215+ pr = PullRequests . FirstOrDefault ( pr => pr . PullRequest == pullrequestnumber ) ;
211216 if ( pr == null )
212217 throw new Exception ( $ "Cannot find POStats pull request number: { pullrequestnumber } ") ;
218+ if ( pr . Commit != pr . Commit )
219+ throw new Exception ( $ "PR { pullrequestnumber } :{ commitid } is not the latest commit { pr . Commit } , cannot save stats.") ;
213220
214- return pr . Outputs . Count ;
221+ return pr . Status . Count ;
215222 }
216223
217224 public bool SaveChangesMultipleTries ( int retries = 0 )
0 commit comments