fix: do not overwrite whole file

This commit is contained in:
Patrick 2024-11-15 13:23:33 +01:00
parent 622cb26a3e
commit 1e3cba55bf
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F

View file

@ -1,7 +1,7 @@
use std::{
env,
fmt::Write,
fs::{self, File},
fs::{self, File, OpenOptions},
io::{self, BufRead, BufReader},
};
@ -219,7 +219,9 @@ async fn main() -> Result<()> {
get_diff(pr, &opts.path, &client).await?;
let pr = get_pr(pr, &client).await?;
let title = pr.title.replace("\n", "//");
fs::write(&opts.pr_file, format!("{} # {}", pr.number, title))?;
let mut file = OpenOptions::new().append(true).open(&opts.pr_file)?;
use std::io::Write;
writeln!(file, "{} # {}", pr.number, title)?;
}
};
Ok(())