From 1ac30e8d0b73a152dce1c9a4951f1f0d5c8079eb Mon Sep 17 00:00:00 2001 From: jyn Date: Mon, 18 Dec 2023 16:35:08 -0500 Subject: [PATCH] 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 --- src/handlers.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/handlers.rs b/src/handlers.rs index d2bf47d8..4edd9c38 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -178,7 +178,17 @@ macro_rules! command_handlers { errors: &mut Vec, ) { 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;