Explorar el Código

don't re-run command handlers when a pr title is edited

doing so leads to weird errors:

> Could not assign reviewer from: jyn514.
> User(s) jyn514 are either the PR author, already assigned, or on vacation, and there are no other candidates.
> Use r? to specify someone else to assign.

this was likely missed when transitioning from highfive to triagebot.

see https://github.com/rust-lang/rust/pull/118993 for an example of a bug this fixes
jyn hace 1 año
padre
commit
1ac30e8d0b
Se han modificado 1 ficheros con 11 adiciones y 1 borrados
  1. 11 1
      src/handlers.rs

+ 11 - 1
src/handlers.rs

@@ -178,7 +178,17 @@ macro_rules! command_handlers {
             errors: &mut Vec<HandlerError>,
         ) {
             match event {
-                Event::Issue(e) => if !matches!(e.action, IssuesAction::Opened | IssuesAction::Edited) {
+                // always handle new PRs / issues
+                Event::Issue(IssuesEvent { action: IssuesAction::Opened, .. }) => {},
+                Event::Issue(IssuesEvent { action: IssuesAction::Edited, .. }) => {
+                    // if the issue was edited, but we don't get a `changes[body]` diff, it means only the title was edited, not the body.
+                    // don't process the same commands twice.
+                    if event.comment_from().is_none() {
+                        log::debug!("skipping title-only edit event");
+                        return;
+                    }
+                },
+                Event::Issue(e) => {
                     // no change in issue's body for these events, so skip
                     log::debug!("skipping event, issue was {:?}", e.action);
                     return;