From 7ef8b43102b73027ebbcf320cfab0d6a87c4d30a Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 4 Jun 2020 16:58:02 +0530 Subject: [PATCH] strikethrough completed PRs --- src/api/search.rs | 17 +++++++++++++++-- src/markdown.rs | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/api/search.rs b/src/api/search.rs index bf7ae8f..6832f3c 100644 --- a/src/api/search.rs +++ b/src/api/search.rs @@ -17,6 +17,14 @@ pub struct PullRequestRef { sha: String, } +#[derive(Deserialize, Debug, Clone)] +pub enum PullRequestStatus { + #[serde(rename = "open")] + Open, + #[serde(rename = "closed")] + Closed +} + #[derive(Deserialize, Debug, Clone)] pub struct PullRequest { id: usize, @@ -26,6 +34,7 @@ pub struct PullRequest { title: String, url: String, body: String, + state: PullRequestStatus } impl PullRequest { @@ -44,8 +53,12 @@ impl PullRequest { pub fn number(&self) -> usize { self.number } - pub fn title(&self) -> &str { - &self.title + + pub fn title(&self) -> String { + match &self.state { + PullRequestStatus::Open => self.title.to_owned(), + PullRequestStatus::Closed => format!("~~{}~~", &self.title.trim()) + } } pub fn body(&self) -> &str { diff --git a/src/markdown.rs b/src/markdown.rs index 1dc6fe4..c54096a 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -8,7 +8,7 @@ use crate::api::search::PullRequest; fn process(row: String) -> String { // TODO: Make this configurable - let regex = Regex::new(r"\[HEAP-\d+\]").unwrap(); + let regex = Regex::new(r"\[HEAP-\d+\]\s*").unwrap(); regex.replace_all(&row, "").into_owned() }