Skip to content

Commit 846eb97

Browse files
committed
Implement command diffing for assign
1 parent 7d39688 commit 846eb97

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/handlers/assign.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,29 @@ impl Handler for AssignmentHandler {
4747
};
4848

4949
if let Event::Issue(e) = event {
50-
if e.action != github::IssuesAction::Opened {
50+
if !matches!(e.action, github::IssuesAction::Opened | github::IssuesAction::Edited) {
5151
log::debug!("skipping event, issue was {:?}", e.action);
52-
// skip events other than opening the issue to avoid retriggering commands in the
52+
// skip events other than opening or editing the issue to avoid retriggering commands in the
5353
// issue body
5454
return Ok(None);
5555
}
5656
}
5757

5858
let mut input = Input::new(&body, &ctx.username);
59-
match input.parse_command() {
59+
let command = input.parse_command();
60+
61+
if let Some(previous) = event.comment_from() {
62+
let mut prev_input = Input::new(&previous, &ctx.username);
63+
let prev_command = prev_input.parse_command();
64+
if command == prev_command {
65+
log::info!("skipping unmodified command: {:?} -> {:?}", prev_command, command);
66+
return Ok(None);
67+
} else {
68+
log::debug!("executing modified command: {:?} -> {:?}", prev_command, command);
69+
}
70+
}
71+
72+
match command {
6073
Command::Assign(Ok(command)) => Ok(Some(command)),
6174
Command::Assign(Err(err)) => {
6275
return Err(format!(

0 commit comments

Comments
 (0)