瀏覽代碼

Act on issue being labeled for prioritization

This helps speed up the workflow for triage, as just labeling an issue will open
up the relevant Zulip streams and such.
Mark Rousskov 5 年之前
父節點
當前提交
9963dc8607
共有 2 個文件被更改,包括 12 次插入1 次删除
  1. 2 0
      src/github.rs
  2. 10 1
      src/handlers/prioritize.rs

+ 2 - 0
src/github.rs

@@ -476,6 +476,8 @@ pub struct IssuesEvent {
     #[serde(alias = "pull_request")]
     pub issue: Issue,
     pub repository: Repository,
+    /// Some if action is IssuesAction::Labeled, for example
+    pub label: Option<Label>,
 }
 
 #[derive(Debug, serde::Deserialize)]

+ 10 - 1
src/handlers/prioritize.rs

@@ -18,7 +18,7 @@ impl Handler for PrioritizeHandler {
         &self,
         ctx: &Context,
         event: &Event,
-        _: Option<&Self::Config>,
+        config: Option<&Self::Config>,
     ) -> Result<Option<Self::Input>, String> {
         let body = if let Some(b) = event.comment_body() {
             b
@@ -28,6 +28,15 @@ impl Handler for PrioritizeHandler {
         };
 
         if let Event::Issue(e) = event {
+            if e.action == github::IssuesAction::Labeled {
+                if let Some(config) = config {
+                    if e.label.as_ref().expect("label").name == config.label {
+                        // We need to take the exact same action in this case.
+                        return Ok(Some(PrioritizeCommand));
+                    }
+                }
+            }
+
             if e.action != github::IssuesAction::Opened {
                 log::debug!("skipping event, issue was {:?}", e.action);
                 // skip events other than opening the issue to avoid retriggering commands in the