From 99f8dcce0276dbc7df2689e8f8b101ab31b4746d Mon Sep 17 00:00:00 2001 From: Bernhard Guillon Date: Tue, 16 Sep 2025 22:51:36 +0200 Subject: future-me: add a hacky way to list all bug reports ================================================================= new | Hello world +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ this is my first bug report ================================================================= new | Hello second bug +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ This is the second bug yey - looks nice --- src/main.rs | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7248942..a25a5f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use std::{ }; use std::fs; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] struct BugReport { timestamp: String, status: String, @@ -56,6 +56,60 @@ fn new_bug() { print!("{}", j); } +fn show() { + let reports = get_reports(); + for report in reports { + //println!("{:?}", report); + println!("================================================================="); + println!("{} | {}", report.status, report.title); + println!("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + for l in report.description { + println!("{}", l); + } + } +} + +fn get_reports() -> Vec { + let mut ret: Vec = Vec::new(); + let output = Command::new("git") + .arg("ls-tree") + .arg("--full-tree") + .arg("-r") + .arg("refs/notes/devtools/future-me") + .output() + .expect("Error with git ls-tree"); + //println!("{}", output.status); + if output.status.success() { + let lines = String::from_utf8_lossy(&output.stdout); + for line in lines.lines() { + if let Some(after_blob) = line.split_once("blob ") { + if let Some((hash, _)) = after_blob.1.split_once('\t') { + let blob = Command::new("git") + .arg("cat-file") + .arg("-p") + .arg(hash) + .output() + .expect("Error with git cat-file"); + if blob.status.success() { + let lines = String::from_utf8_lossy(&blob.stdout); + // TODO: error handling + let bug_report: BugReport = serde_json::from_str(&lines).unwrap(); + ret.push(bug_report); + } + else { + println!("{}", String::from_utf8_lossy(&blob.stderr)); + } + } + } + } + } + else { + println!("{}", String::from_utf8_lossy(&output.stderr)); + } + ret +} + fn main() { - new_bug(); + //new_bug(); + show(); } -- cgit v1.2.3