@@ -424,32 +424,40 @@ impl Processor {
424424 // Record vote_id as part of the current span
425425 tracing:: Span :: current ( ) . record ( "vote_id" , & vote. vote_id . to_string ( ) ) ;
426426
427- // Post vote closed comment on the issue/pr
427+ // Post vote closed comment on the issue/pr if results were returned
428+ // (i.e. if the vote comment was removed, the vote will be closed but
429+ // no results will be received)
428430 let inst_id = vote. installation_id as u64 ;
429431 let ( owner, repo) = split_full_name ( & vote. repository_full_name ) ;
430- let body = tmpl:: VoteClosed :: new ( & results) . render ( ) ?;
431- self . gh
432- . post_comment ( inst_id, owner, repo, vote. issue_number , & body)
433- . await ?;
432+ if let Some ( results) = & results {
433+ let body = tmpl:: VoteClosed :: new ( results) . render ( ) ?;
434+ self . gh
435+ . post_comment ( inst_id, owner, repo, vote. issue_number , & body)
436+ . await ?;
437+ }
434438
435439 // Create check run if the vote is on a pull request
436440 if vote. is_pull_request {
437- let ( conclusion, summary) = if results. passed {
438- (
439- "success" ,
440- format ! (
441- "The vote passed! {} out of {} voted in favor." ,
442- results. in_favor, results. allowed_voters
443- ) ,
444- )
441+ let ( conclusion, summary) = if let Some ( results) = & results {
442+ if results. passed {
443+ (
444+ "success" ,
445+ format ! (
446+ "The vote passed! {} out of {} voted in favor." ,
447+ results. in_favor, results. allowed_voters
448+ ) ,
449+ )
450+ } else {
451+ (
452+ "failure" ,
453+ format ! (
454+ "The vote did not pass. {} out of {} voted in favor." ,
455+ results. in_favor, results. allowed_voters
456+ ) ,
457+ )
458+ }
445459 } else {
446- (
447- "failure" ,
448- format ! (
449- "The vote did not pass. {} out of {} voted in favor." ,
450- results. in_favor, results. allowed_voters
451- ) ,
452- )
460+ ( "success" , "The vote was cancelled" . to_string ( ) )
453461 } ;
454462 let check_details = CheckDetails {
455463 status : "completed" . to_string ( ) ,
@@ -1194,7 +1202,7 @@ mod tests {
11941202 db. expect_close_finished_vote ( ) . returning ( move |_| {
11951203 Box :: pin ( future:: ready ( Ok ( Some ( (
11961204 setup_test_vote ( ) ,
1197- results_copy. clone ( ) ,
1205+ Some ( results_copy. clone ( ) ) ,
11981206 ) ) ) ) )
11991207 } ) ;
12001208 let mut gh = MockGH :: new ( ) ;
@@ -1222,7 +1230,7 @@ mod tests {
12221230 db. expect_close_finished_vote ( ) . returning ( move |_| {
12231231 let mut vote = setup_test_vote ( ) ;
12241232 vote. is_pull_request = true ;
1225- Box :: pin ( future:: ready ( Ok ( Some ( ( vote, results_copy. clone ( ) ) ) ) ) )
1233+ Box :: pin ( future:: ready ( Ok ( Some ( ( vote, Some ( results_copy. clone ( ) ) ) ) ) ) )
12261234 } ) ;
12271235 let mut gh = MockGH :: new ( ) ;
12281236 gh. expect_post_comment ( )
@@ -1266,7 +1274,7 @@ mod tests {
12661274 db. expect_close_finished_vote ( ) . returning ( move |_| {
12671275 let mut vote = setup_test_vote ( ) ;
12681276 vote. is_pull_request = true ;
1269- Box :: pin ( future:: ready ( Ok ( Some ( ( vote, results_copy. clone ( ) ) ) ) ) )
1277+ Box :: pin ( future:: ready ( Ok ( Some ( ( vote, Some ( results_copy. clone ( ) ) ) ) ) ) )
12701278 } ) ;
12711279 let mut gh = MockGH :: new ( ) ;
12721280 gh. expect_post_comment ( )
0 commit comments