소스 검색

Add to-announce label to major-change-accepted proposals

Santiago Pastorino 4 년 전
부모
커밋
549ef8c2d6
2개의 변경된 파일29개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      Cargo.lock
  2. 28 1
      src/handlers/major_change.rs

+ 1 - 1
Cargo.lock

@@ -445,7 +445,7 @@ name = "globset"
 version = "0.4.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "aho-corasick 0.7.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "bstr 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",

+ 28 - 1
src/handlers/major_change.rs

@@ -12,6 +12,7 @@ use parser::command::{Command, Input};
 pub(super) enum Invocation {
     Second,
     NewProposal,
+    AcceptedProposal,
 }
 
 pub(super) struct MajorChangeHandler;
@@ -50,7 +51,15 @@ impl Handler for MajorChangeHandler {
 
         if let Event::Issue(e) = event {
             if e.issue.labels().iter().any(|l| l.name == "major-change") {
-                return Ok(Some(Invocation::NewProposal));
+                if e.issue
+                    .labels()
+                    .iter()
+                    .any(|l| l.name == "major-change-accepted")
+                {
+                    return Ok(Some(Invocation::AcceptedProposal));
+                } else {
+                    return Ok(Some(Invocation::NewProposal));
+                }
             }
         }
 
@@ -133,6 +142,24 @@ async fn handle_input(
                 event.html_url().unwrap()
             ), config.meeting_label.clone())
         }
+        Invocation::AcceptedProposal => {
+            if !issue.labels().iter().any(|l| l.name == "major-change") {
+                let cmnt = ErrorComment::new(
+                    &issue,
+                    "This is not a major change (it lacks the `major-change` label).",
+                );
+                cmnt.post(&ctx.github).await?;
+                return Ok(());
+            }
+            (
+                format!(
+                    "This proposal has been accepted: [#{}]({}).",
+                    issue.number,
+                    event.html_url().unwrap()
+                ),
+                config.meeting_label.clone(),
+            )
+        }
     };
 
     let mut labels = issue.labels().to_owned();