strikethrough completed PRs

This commit is contained in:
Timothy Andrew 2020-06-04 16:58:02 +05:30
parent 7b131d8b6b
commit 7ef8b43102
No known key found for this signature in database
GPG Key ID: ABD64509E977B249
2 changed files with 16 additions and 3 deletions

View File

@ -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 {

View File

@ -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()
}