@@ -20,20 +20,17 @@ pub(super) async fn command_approve(
20
20
approver : & Approver ,
21
21
) -> anyhow:: Result < ( ) > {
22
22
tracing:: info!( "Approving PR {}" , pr. number) ;
23
- if insufficient_approve_permission ( repo_state. clone ( ) , author) {
23
+ if ! sufficient_approve_permission ( repo_state. clone ( ) , author) {
24
24
deny_approve_request ( & repo_state, pr, author) . await ?;
25
25
return Ok ( ( ) ) ;
26
26
} ;
27
27
let approver = match approver {
28
28
Approver :: Myself => author. username . clone ( ) ,
29
29
Approver :: Specified ( approver) => approver. clone ( ) ,
30
30
} ;
31
- tracing:: info!( "Approving PR {} by {}" , pr. number, approver) ;
32
31
db. approve ( repo_state. repository ( ) , pr. number , approver. as_str ( ) )
33
32
. await ?;
34
- tracing:: info!( "Approved PR {}" , pr. number) ;
35
33
handle_label_trigger ( & repo_state, pr. number , LabelTrigger :: Approved ) . await ?;
36
- tracing:: info!( "Label trigger handled for PR {}" , pr. number) ;
37
34
notify_of_approval ( & repo_state, pr, approver. as_str ( ) ) . await
38
35
}
39
36
@@ -46,7 +43,7 @@ pub(super) async fn command_unapprove(
46
43
author : & GithubUser ,
47
44
) -> anyhow:: Result < ( ) > {
48
45
tracing:: info!( "Unapproving PR {}" , pr. number) ;
49
- if insufficient_unapprove_permission ( repo_state. clone ( ) , pr, author) {
46
+ if ! sufficient_unapprove_permission ( repo_state. clone ( ) , pr, author) {
50
47
deny_unapprove_request ( & repo_state, pr, author) . await ?;
51
48
return Ok ( ( ) ) ;
52
49
} ;
@@ -55,9 +52,8 @@ pub(super) async fn command_unapprove(
55
52
notify_of_unapproval ( & repo_state, pr) . await
56
53
}
57
54
58
- fn insufficient_approve_permission ( repo : Arc < RepositoryState > , author : & GithubUser ) -> bool {
59
- !repo
60
- . permissions
55
+ fn sufficient_approve_permission ( repo : Arc < RepositoryState > , author : & GithubUser ) -> bool {
56
+ repo. permissions
61
57
. load ( )
62
58
. has_permission ( author. id , PermissionType :: Review )
63
59
}
@@ -98,13 +94,13 @@ async fn notify_of_approval(
98
94
. await
99
95
}
100
96
101
- fn insufficient_unapprove_permission (
97
+ fn sufficient_unapprove_permission (
102
98
repo : Arc < RepositoryState > ,
103
99
pr : & PullRequest ,
104
100
author : & GithubUser ,
105
101
) -> bool {
106
- author. id ! = pr. author . id
107
- && ! repo
102
+ author. id = = pr. author . id
103
+ || repo
108
104
. permissions
109
105
. load ( )
110
106
. has_permission ( author. id , PermissionType :: Review )
0 commit comments