File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,10 @@ pub(super) async fn command_approve(
38
38
return Ok ( ( ) ) ;
39
39
} ;
40
40
41
- if ! matches ! ( pr . github . status , PullRequestStatus :: Open ) {
41
+ if let Some ( error_comment ) = check_pr_approval_validity ( pr ) . await ? {
42
42
repo_state
43
43
. client
44
- . post_comment ( pr. number ( ) , approve_non_open_pr_comment ( ) )
44
+ . post_comment ( pr. number ( ) , error_comment )
45
45
. await ?;
46
46
return Ok ( ( ) ) ;
47
47
}
@@ -62,6 +62,16 @@ pub(super) async fn command_approve(
62
62
notify_of_approval ( & repo_state, pr, approver. as_str ( ) ) . await
63
63
}
64
64
65
+ /// Check that the given PR can be approved in its current state.
66
+ /// Returns `Ok(Some(comment))` if it **cannot** be approved; the comment should be sent to the
67
+ /// pull request.
68
+ async fn check_pr_approval_validity ( pr : & PullRequestData ) -> anyhow:: Result < Option < Comment > > {
69
+ if !matches ! ( pr. github. status, PullRequestStatus :: Open ) {
70
+ return Ok ( Some ( approve_non_open_pr_comment ( ) ) ) ;
71
+ }
72
+ Ok ( None )
73
+ }
74
+
65
75
/// Unapprove a pull request.
66
76
/// Pull request's author can also unapprove the pull request.
67
77
pub ( super ) async fn command_unapprove (
You can’t perform that action at this time.
0 commit comments