Browse Source

Merge pull request #649 from spastorino/to-announce-major-accepted

Add to-announce label to major-change-accepted proposals
Mark Rousskov 4 years ago
parent
commit
f0ba6d8382
4 changed files with 33 additions and 17 deletions
  1. 1 1
      Cargo.lock
  2. 2 13
      src/github.rs
  3. 28 1
      src/handlers/major_change.rs
  4. 2 2
      src/prioritization.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)",

+ 2 - 13
src/github.rs

@@ -644,10 +644,7 @@ impl Repository {
             ..
         } = query;
 
-        let use_issues = exclude_labels.is_empty()
-            && filters
-                .iter()
-                .all(|&(key, _)| key != "no" && key != "closed-days-ago");
+        let use_issues = exclude_labels.is_empty() || filters.iter().any(|&(key, _)| key == "no");
         // negating filters can only be handled by the search api
         let url = if use_issues {
             self.build_issues_url(filters, include_labels)
@@ -708,15 +705,7 @@ impl Repository {
     ) -> String {
         let filters = filters
             .iter()
-            .map(|(key, val)| {
-                if *key == "closed-days-ago" {
-                    let last_week =
-                        Utc::now() - chrono::Duration::days(val.parse::<i64>().unwrap());
-                    format!("closed:>={}", last_week.format("%Y-%m-%d"))
-                } else {
-                    format!("{}:{}", key, val)
-                }
-            })
+            .map(|(key, val)| format!("{}:{}", key, val))
             .chain(
                 include_labels
                     .iter()

+ 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();

+ 2 - 2
src/prioritization.rs

@@ -237,8 +237,8 @@ pub fn agenda<'a>() -> Box<Step<'a>> {
         name: "mcp_accepted",
         query: github::Query {
             kind: github::QueryKind::List,
-            filters: vec![("state", "closed"), ("closed-days-ago", "7")],
-            include_labels: vec!["major-change-accepted"],
+            filters: vec![("state", "all")],
+            include_labels: vec!["major-change-accepted", "to-announce"],
             exclude_labels: vec![],
         },
     });