@@ -614,8 +614,7 @@ impl<'a> RfcBotCommand<'a> {
614
614
}
615
615
616
616
struct RfcBotComment < ' a > {
617
- repository : & ' a str ,
618
- issue_num : i32 ,
617
+ issue : & ' a Issue ,
619
618
comment_type : CommentType < ' a > ,
620
619
}
621
620
@@ -637,8 +636,7 @@ impl<'a> RfcBotComment<'a> {
637
636
fn new ( issue : & ' a Issue , comment_type : CommentType < ' a > ) -> RfcBotComment < ' a > {
638
637
639
638
RfcBotComment {
640
- repository : & issue. repository ,
641
- issue_num : issue. number ,
639
+ issue : & issue,
642
640
comment_type : comment_type,
643
641
}
644
642
}
@@ -731,9 +729,9 @@ impl<'a> RfcBotComment<'a> {
731
729
732
730
fn add_comment_url ( & self , msg : & mut String , comment_id : i32 ) {
733
731
msg. push_str ( "https://github.com/" ) ;
734
- msg. push_str ( & self . repository ) ;
732
+ msg. push_str ( & self . issue . repository ) ;
735
733
msg. push_str ( "/issues/" ) ;
736
- msg. push_str ( & self . issue_num . to_string ( ) ) ;
734
+ msg. push_str ( & self . issue . number . to_string ( ) ) ;
737
735
msg. push_str ( "#issuecomment-" ) ;
738
736
msg. push_str ( & comment_id. to_string ( ) ) ;
739
737
}
@@ -745,17 +743,25 @@ impl<'a> RfcBotComment<'a> {
745
743
746
744
if CONFIG . post_comments {
747
745
748
- let text = self . format ( ) ?;
746
+ if self . issue . open {
747
+ let text = self . format ( ) ?;
749
748
750
- Ok ( match existing_comment {
751
- Some ( comment_id) => GH . edit_comment ( self . repository , comment_id, & text) ,
752
- None => GH . new_comment ( self . repository , self . issue_num , & text) ,
753
- } ?)
749
+ Ok ( match existing_comment {
750
+ Some ( comment_id) => GH . edit_comment ( & self . issue . repository , comment_id, & text) ,
751
+ None => GH . new_comment ( & self . issue . repository , self . issue . number , & text) ,
752
+ } ?)
753
+ } else {
754
+ info ! ( "Skipping comment to {}#{}, the issue is no longer open" ,
755
+ self . issue. repository,
756
+ self . issue. number) ;
757
+
758
+ Err ( DashError :: Misc ( None ) )
759
+ }
754
760
755
761
} else {
756
762
info ! ( "Skipping comment to {}#{}, comment posts are disabled." ,
757
- self . repository,
758
- self . issue_num ) ;
763
+ self . issue . repository,
764
+ self . issue . number ) ;
759
765
Err ( DashError :: Misc ( None ) )
760
766
}
761
767
}
0 commit comments