Highlight current PR
This commit is contained in:
parent
ec46361f1e
commit
eef30d7a68
@ -1,15 +1,8 @@
|
||||
use regex::Regex;
|
||||
use std::fs;
|
||||
|
||||
use crate::api::{PullRequestReviewState, PullRequestStatus};
|
||||
use crate::graph::FlatDep;
|
||||
|
||||
fn process(row: String) -> String {
|
||||
// TODO: Make this configurable
|
||||
let regex = Regex::new(r"\[[^\]]+\]\s*").unwrap();
|
||||
regex.replace_all(&row, "").into_owned()
|
||||
}
|
||||
|
||||
pub fn build_table(deps: &FlatDep, title: &str, prelude_path: Option<&str>) -> String {
|
||||
let is_complete = deps
|
||||
.iter()
|
||||
@ -67,7 +60,7 @@ pub fn build_table(deps: &FlatDep, title: &str, prelude_path: Option<&str>) -> S
|
||||
),
|
||||
};
|
||||
|
||||
out.push_str(&process(row));
|
||||
out.push_str(&row);
|
||||
}
|
||||
|
||||
out
|
||||
|
@ -27,9 +27,18 @@ fn safe_replace(body: &str, table: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_title_prefixes(row: String) -> String {
|
||||
// TODO: Make this configurable
|
||||
let regex = Regex::new(r"\[[^\]]+\]\s*").unwrap();
|
||||
regex.replace_all(&row, "").into_owned()
|
||||
}
|
||||
|
||||
|
||||
pub async fn persist(prs: &FlatDep, table: &str, c: &Credentials) -> Result<(), Box<dyn Error>> {
|
||||
let futures = prs.iter().map(|(pr, _)| {
|
||||
let description = safe_replace(pr.body(), table);
|
||||
let body = table.replace(&pr.title()[..], &format!("👉 {}", pr.title())[..]);
|
||||
let body = remove_title_prefixes(body);
|
||||
let description = safe_replace(pr.body(), body.as_ref());
|
||||
pull_request::update_description(description, pr.clone(), c)
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user