浏览代码

Add new_pr autolabel.

This adds a setting to the auto-label handler so that it can
automatically add a label to all new PRs.
Eric Huss 2 年之前
父节点
当前提交
b542f2a11f
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 2 0
      src/config.rs
  2. 5 0
      src/handlers/autolabel.rs

+ 2 - 0
src/config.rs

@@ -142,6 +142,8 @@ pub(crate) struct AutolabelLabelConfig {
     pub(crate) exclude_labels: Vec<String>,
     pub(crate) exclude_labels: Vec<String>,
     #[serde(default)]
     #[serde(default)]
     pub(crate) trigger_files: Vec<String>,
     pub(crate) trigger_files: Vec<String>,
+    #[serde(default)]
+    pub(crate) new_pr: bool,
 }
 }
 
 
 #[derive(PartialEq, Eq, Debug, serde::Deserialize)]
 #[derive(PartialEq, Eq, Debug, serde::Deserialize)]

+ 5 - 0
src/handlers/autolabel.rs

@@ -68,6 +68,11 @@ pub(super) async fn parse_input(
                         name: label.to_owned(),
                         name: label.to_owned(),
                     });
                     });
                 }
                 }
+                if cfg.new_pr && event.action == IssuesAction::Opened {
+                    autolabels.push(Label {
+                        name: label.to_owned(),
+                    });
+                }
             }
             }
             if !autolabels.is_empty() {
             if !autolabels.is_empty() {
                 return Ok(Some(AutolabelInput {
                 return Ok(Some(AutolabelInput {