parsed `pijul log` text blob into individual entries & fields

CrepeGoat
Oct 9, 2024, 5:03 AM
G2CHQAOPRFFDCYVNDXMTB5Y5J2FBRREJPMUAJJTVQDSZE3VFLP3QC

Dependencies

  • [2] IQY5LHEN add GUI element to display simple `pijul log` results
  • [3] NSE6BLWA init slint project from https://github.com/slint-ui/slint-rust-template
  • [4] 4RPYR65C connect GUI to pijul to display simple channel list
  • [*] NCRTU7M4 cargo init

Change contents

  • edit in ui/app-window.slint at line 2
    [2.84]
    [3.115]
    export struct ChangeData {
    hash: string,
    // TODO display all authors
    // authors: [string],
    author: string,
    timestamp: string,
    message: string,
    }
    component ChangeEntry {
    in-out property <string> hash;
    in-out property <string> author;
    in-out property <string> timestamp;
    in-out property <string> message;
    VerticalBox {
    spacing: 0;
    Text {
    text: "hash \{root.hash}";
    }
    Text {
    text: "author \{root.author}";
    }
  • edit in ui/app-window.slint at line 28
    [3.116]
    [3.116]
    Text {
    text: "timestamp \{root.timestamp}";
    }
    HorizontalBox {
    alignment: start;
    spacing: 0;
    padding: 5px;
    Rectangle {
    width: 10px;
    visible: false;
    }
    Text {
    text: "\{root.message}";
    }
    }
    }
    }
  • replacement in ui/app-window.slint at line 51
    [3.47][2.85:131]()
    in-out property <string> changes_log: "";
    [3.47]
    [3.47]
    in-out property <[ChangeData]> changes_log: [];
  • replacement in ui/app-window.slint at line 90
    [2.873][2.873:953]()
    Text {
    text: "\{root.changes_log}";
    [2.873]
    [2.953]
    for change in root.changes_log: ChangeEntry {
    hash: change.hash;
    author: change.author;
    timestamp: change.timestamp;
    message: change.message;
  • replacement in src/main.rs at line 10
    [2.1044][3.288:313](),[3.288][3.288:313]()
    use slint::SharedString;
    [2.1044]
    [3.733]
    use slint::{ModelRc, SharedString};
  • replacement in src/main.rs at line 53
    [2.1588][2.1588:1646]()
    ui.set_changes_log(SharedString::from(&log));
    [2.1588]
    [3.1019]
    let log_strs: Vec<ChangeData> = log
    .into_iter()
    .map(|change| ChangeData {
    hash: change.hash.into(),
    author: change
    .authors
    .first()
    .unwrap_or(&String::new())
    .clone()
    .into(),
    timestamp: change.timestamp.into(),
    message: change.message.into(),
    })
    .collect();
    ui.set_changes_log((&log_strs[..]).into());
  • replacement in src/cmds.rs at line 16
    [2.1845][2.1845:1930]()
    pub fn log(exe: &std::path::Path, repo: &std::path::Path) -> Result<String, Error> {
    [2.1845]
    [2.1930]
    pub fn log(exe: &std::path::Path, repo: &std::path::Path) -> Result<Vec<ChangelogEntry>, Error> {
  • replacement in src/cmds.rs at line 22
    [3.1204][3.1204:1224]()
    .arg(repo);
    [3.1204]
    [3.1224]
    .arg(repo)
    .arg("--output-format")
    .arg("json");
  • replacement in src/cmds.rs at line 27
    [3.1300][3.1300:1342]()
    Ok(String::from_utf8(output.stdout)?)
    [3.1300]
    [3.1342]
    Ok(serde_json::from_slice(&output.stdout)?)
  • edit in src/cmds.rs at line 47
    [3.1928]
    [3.1928]
    }
    #[derive(serde::Serialize, serde::Deserialize, Debug)]
    pub struct ChangelogEntry {
    pub(crate) hash: String,
    pub(crate) authors: Vec<String>,
    pub(crate) timestamp: String,
    pub(crate) message: String,
  • edit in Cargo.toml at line 10
    [3.1308]
    [3.1931]
    serde = { version = "1.0.210", features = ["derive"] }
    serde_json = "1.0.128"
  • edit in Cargo.lock at line 2804
    [3.2174]
    [3.69755]
    "serde",
    "serde_json",