Ver código fonte

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 anos atrás
pai
commit
9963dc8607
2 arquivos alterados com 12 adições e 1 exclusões
  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")]
     #[serde(alias = "pull_request")]
     pub issue: Issue,
     pub issue: Issue,
     pub repository: Repository,
     pub repository: Repository,
+    /// Some if action is IssuesAction::Labeled, for example
+    pub label: Option<Label>,
 }
 }
 
 
 #[derive(Debug, serde::Deserialize)]
 #[derive(Debug, serde::Deserialize)]

+ 10 - 1
src/handlers/prioritize.rs

@@ -18,7 +18,7 @@ impl Handler for PrioritizeHandler {
         &self,
         &self,
         ctx: &Context,
         ctx: &Context,
         event: &Event,
         event: &Event,
-        _: Option<&Self::Config>,
+        config: Option<&Self::Config>,
     ) -> Result<Option<Self::Input>, String> {
     ) -> Result<Option<Self::Input>, String> {
         let body = if let Some(b) = event.comment_body() {
         let body = if let Some(b) = event.comment_body() {
             b
             b
@@ -28,6 +28,15 @@ impl Handler for PrioritizeHandler {
         };
         };
 
 
         if let Event::Issue(e) = event {
         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 {
             if e.action != github::IssuesAction::Opened {
                 log::debug!("skipping event, issue was {:?}", e.action);
                 log::debug!("skipping event, issue was {:?}", e.action);
                 // skip events other than opening the issue to avoid retriggering commands in the
                 // skip events other than opening the issue to avoid retriggering commands in the