Forráskód Böngészése

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 éve
szülő
commit
9963dc8607
2 módosított fájl, 12 hozzáadás és 1 törlés
  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