feat: allow comments in tracking file
This commit is contained in:
parent
070f5b2d49
commit
95eaf0190c
26
src/main.rs
26
src/main.rs
|
@ -1,4 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
|
fmt::Write,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{self, BufRead},
|
io::{self, BufRead},
|
||||||
};
|
};
|
||||||
|
@ -134,11 +135,16 @@ async fn main() -> Result<()> {
|
||||||
get_diff(pr, &opts.path, &client).await?;
|
get_diff(pr, &opts.path, &client).await?;
|
||||||
}
|
}
|
||||||
CliCommands::UpdatePrs(opts) => {
|
CliCommands::UpdatePrs(opts) => {
|
||||||
let mut trackable: Vec<u32> = Vec::new();
|
let mut trackable: Vec<(u32, String)> = Vec::new();
|
||||||
{
|
{
|
||||||
let file = File::open(opts.pr_file.clone())?;
|
let file = File::open(opts.pr_file.clone())?;
|
||||||
for l in io::BufReader::new(file).lines() {
|
for l in io::BufReader::new(file).lines() {
|
||||||
let l = l?.parse::<u32>()?;
|
let l = l?;
|
||||||
|
let l = if let Some((pr, _)) = l.split_once("#") {
|
||||||
|
pr.parse::<u32>()?
|
||||||
|
} else {
|
||||||
|
bail!("Could not parse line")
|
||||||
|
};
|
||||||
let pr = get_pr(l, &client).await?;
|
let pr = get_pr(l, &client).await?;
|
||||||
println!("Fetching diff for PR #{}: {}", l, pr.title);
|
println!("Fetching diff for PR #{}: {}", l, pr.title);
|
||||||
if contains(&opts.branch, &pr, &client).await? {
|
if contains(&opts.branch, &pr, &client).await? {
|
||||||
|
@ -146,17 +152,17 @@ async fn main() -> Result<()> {
|
||||||
fs::remove_file(format!("{}/{}.diff", opts.path, l))?;
|
fs::remove_file(format!("{}/{}.diff", opts.path, l))?;
|
||||||
} else {
|
} else {
|
||||||
get_diff(l, &opts.path, &client).await?;
|
get_diff(l, &opts.path, &client).await?;
|
||||||
trackable.push(l.clone());
|
trackable.push((l, pr.title));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs::write(
|
let mut str = String::new();
|
||||||
&opts.pr_file,
|
for (pr, title) in trackable {
|
||||||
trackable
|
let title = title.replace("\n", "//");
|
||||||
.iter()
|
writeln!(&mut str, "{} # {}", pr, title)?;
|
||||||
.map(|x| format!("{}\n", x))
|
}
|
||||||
.collect::<String>(),
|
|
||||||
)?;
|
fs::write(&opts.pr_file, str)?;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue