File tree 6 files changed +84
-37
lines changed 6 files changed +84
-37
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,17 @@ impl Handler for GlacierHandler {
32
32
} ;
33
33
34
34
let mut input = Input :: new ( & body, & ctx. username ) ;
35
- match input. parse_command ( ) {
35
+ let command = input. parse_command ( ) ;
36
+
37
+ if let Some ( previous) = event. comment_from ( ) {
38
+ let mut prev_input = Input :: new ( & previous, & ctx. username ) ;
39
+ let prev_command = prev_input. parse_command ( ) ;
40
+ if command == prev_command {
41
+ return Ok ( None ) ;
42
+ }
43
+ }
44
+
45
+ match command {
36
46
Command :: Glacier ( Ok ( command) ) => Ok ( Some ( command) ) ,
37
47
Command :: Glacier ( Err ( err) ) => {
38
48
return Err ( format ! (
Original file line number Diff line number Diff line change @@ -63,15 +63,21 @@ impl Handler for MajorChangeHandler {
63
63
// All other issue events are ignored
64
64
return Ok ( None ) ;
65
65
}
66
- Event :: IssueComment ( e) => {
67
- if e. action != github:: IssueCommentAction :: Created {
68
- return Ok ( None ) ;
69
- }
70
- }
66
+ Event :: IssueComment ( e) => { }
71
67
}
72
68
73
69
let mut input = Input :: new ( & body, & ctx. username ) ;
74
- match input. parse_command ( ) {
70
+ let command = input. parse_command ( ) ;
71
+
72
+ if let Some ( previous) = event. comment_from ( ) {
73
+ let mut prev_input = Input :: new ( & previous, & ctx. username ) ;
74
+ let prev_command = prev_input. parse_command ( ) ;
75
+ if command == prev_command {
76
+ return Ok ( None ) ;
77
+ }
78
+ }
79
+
80
+ match command {
75
81
Command :: Second ( Ok ( SecondCommand ) ) => Ok ( Some ( Invocation :: Second ) ) ,
76
82
_ => Ok ( None ) ,
77
83
}
@@ -107,14 +113,6 @@ async fn handle_input(
107
113
return Ok ( ( ) ) ;
108
114
}
109
115
110
- if !issue. labels ( ) . iter ( ) . any ( |l| l. name == "major-change" ) {
111
- let cmnt = ErrorComment :: new (
112
- & issue,
113
- "This is not a major change (it lacks the `major-change` label)." ,
114
- ) ;
115
- cmnt. post ( & ctx. github ) . await ?;
116
- return Ok ( ( ) ) ;
117
- }
118
116
let is_team_member =
119
117
if let Err ( _) | Ok ( false ) = event. user ( ) . is_team_member ( & ctx. github ) . await {
120
118
false
Original file line number Diff line number Diff line change @@ -30,15 +30,25 @@ impl Handler for NominateHandler {
30
30
} ;
31
31
32
32
if let Event :: Issue ( e) = event {
33
- if e. action != github:: IssuesAction :: Opened {
34
- // skip events other than opening the issue to avoid retriggering commands in the
33
+ if ! matches ! ( e. action, github:: IssuesAction :: Opened | github :: IssuesAction :: Edited ) {
34
+ // skip events other than opening or editing the issue to avoid retriggering commands in the
35
35
// issue body
36
36
return Ok ( None ) ;
37
37
}
38
38
}
39
39
40
40
let mut input = Input :: new ( & body, & ctx. username ) ;
41
- match input. parse_command ( ) {
41
+ let command = input. parse_command ( ) ;
42
+
43
+ if let Some ( previous) = event. comment_from ( ) {
44
+ let mut prev_input = Input :: new ( & previous, & ctx. username ) ;
45
+ let prev_command = prev_input. parse_command ( ) ;
46
+ if command == prev_command {
47
+ return Ok ( None ) ;
48
+ }
49
+ }
50
+
51
+ match command {
42
52
Command :: Nominate ( Ok ( command) ) => Ok ( Some ( command) ) ,
43
53
Command :: Nominate ( Err ( err) ) => {
44
54
return Err ( format ! (
Original file line number Diff line number Diff line change @@ -33,25 +33,26 @@ impl Handler for PingHandler {
33
33
return Ok ( None ) ;
34
34
} ;
35
35
36
- match event {
37
- Event :: Issue ( e) => {
38
- if e. action != github:: IssuesAction :: Opened {
39
- // skip events other than opening the issue to avoid retriggering commands in the
40
- // issue body
41
- return Ok ( None ) ;
42
- }
43
- }
44
- Event :: IssueComment ( e) => {
45
- // Especially on ping commands, which ping tons of folks, this
46
- // is quite noisy.
47
- if e. action != github:: IssueCommentAction :: Created {
48
- return Ok ( None ) ;
49
- }
36
+ if let Event :: Issue ( e) = event {
37
+ if !matches ! ( e. action, github:: IssuesAction :: Opened | github:: IssuesAction :: Edited ) {
38
+ // skip events other than opening or editing the issue to avoid retriggering commands in the
39
+ // issue body
40
+ return Ok ( None ) ;
50
41
}
51
42
}
52
43
53
44
let mut input = Input :: new ( & body, & ctx. username ) ;
54
- match input. parse_command ( ) {
45
+ let command = input. parse_command ( ) ;
46
+
47
+ if let Some ( previous) = event. comment_from ( ) {
48
+ let mut prev_input = Input :: new ( & previous, & ctx. username ) ;
49
+ let prev_command = prev_input. parse_command ( ) ;
50
+ if command == prev_command {
51
+ return Ok ( None ) ;
52
+ }
53
+ }
54
+
55
+ match command {
55
56
Command :: Ping ( Ok ( command) ) => Ok ( Some ( command) ) ,
56
57
Command :: Ping ( Err ( err) ) => {
57
58
return Err ( format ! (
Original file line number Diff line number Diff line change @@ -25,9 +25,27 @@ impl Handler for PrioritizeHandler {
25
25
// not interested in other events
26
26
return Ok ( None ) ;
27
27
} ;
28
+
29
+ if let Event :: Issue ( e) = event {
30
+ if !matches ! ( e. action, github:: IssuesAction :: Opened | github:: IssuesAction :: Edited ) {
31
+ // skip events other than opening or editing the issue to avoid retriggering commands in the
32
+ // issue body
33
+ return Ok ( None ) ;
34
+ }
35
+ }
28
36
29
37
let mut input = Input :: new ( & body, & ctx. username ) ;
30
- match input. parse_command ( ) {
38
+ let command = input. parse_command ( ) ;
39
+
40
+ if let Some ( previous) = event. comment_from ( ) {
41
+ let mut prev_input = Input :: new ( & previous, & ctx. username ) ;
42
+ let prev_command = prev_input. parse_command ( ) ;
43
+ if command == prev_command {
44
+ return Ok ( None ) ;
45
+ }
46
+ }
47
+
48
+ match command {
31
49
Command :: Prioritize ( Ok ( PrioritizeCommand ) ) => Ok ( Some ( PrioritizeCommand ) ) ,
32
50
_ => Ok ( None ) ,
33
51
}
Original file line number Diff line number Diff line change @@ -38,15 +38,25 @@ impl Handler for RelabelHandler {
38
38
} ;
39
39
40
40
if let Event :: Issue ( e) = event {
41
- if e. action != github:: IssuesAction :: Opened {
42
- // skip events other than opening the issue to avoid retriggering commands in the
41
+ if ! matches ! ( e. action, github:: IssuesAction :: Opened | github :: IssuesAction :: Edited ) {
42
+ // skip events other than opening or editing the issue to avoid retriggering commands in the
43
43
// issue body
44
44
return Ok ( None ) ;
45
45
}
46
46
}
47
47
48
48
let mut input = Input :: new ( & body, & ctx. username ) ;
49
- match input. parse_command ( ) {
49
+ let command = input. parse_command ( ) ;
50
+
51
+ if let Some ( previous) = event. comment_from ( ) {
52
+ let mut prev_input = Input :: new ( & previous, & ctx. username ) ;
53
+ let prev_command = prev_input. parse_command ( ) ;
54
+ if command == prev_command {
55
+ return Ok ( None ) ;
56
+ }
57
+ }
58
+
59
+ match command {
50
60
Command :: Relabel ( Ok ( command) ) => Ok ( Some ( command) ) ,
51
61
Command :: Relabel ( Err ( err) ) => {
52
62
return Err ( format ! (
You can’t perform that action at this time.
0 commit comments