added counter for pending diff files

CrepeGoat
Oct 16, 2024, 7:46 AM
3W2E3DX2QDACZBU6VPPBRFO6OUUMEPTGH2BEANQFDH6OWRLXI4FAC

Dependencies

  • [2] BD456SZF added diff view
  • [3] F6YAQWVD added UI for `pijul change`
  • [*] NSE6BLWA init slint project from https://github.com/slint-ui/slint-rust-template
  • [*] I4NM4O3Z make changelog elements interactable
  • [*] XERTHGSY consolidated `pijul log` UI elements into their own component
  • [*] NCRTU7M4 cargo init
  • [*] 4RPYR65C connect GUI to pijul to display simple channel list

Change contents

  • edit in ui/app-window.slint at line 34
    [2.60]
    [2.60]
    in property <int> files-count;
  • replacement in ui/app-window.slint at line 38
    [2.102][2.102:135]()
    text: "active diff";
    [2.102]
    [3.403]
    text: "\{files-count} files changed";
  • edit in ui/app-window.slint at line 105
    [6.718]
    [7.57]
    in-out property <int> count-files-changed;
  • edit in ui/app-window.slint at line 120
    [2.713]
    [2.713]
    files-count: count-files-changed;
  • edit in ui/app-window.slint at line 240
    [7.606]
    [3.521]
    in-out property <int> count-files-changed <=> log.count-files-changed;
  • edit in ui/app-window.slint at line 245
    [3.618]
    [2.996]
    callback request-diff-summary(string);
  • edit in ui/app-window.slint at line 249
    [2.1070]
    [2.1070]
    root.request-diff-summary(chs.channels[chs.selected]);
  • replacement in src/main.rs at line 119
    [2.1740][2.1740:1771]()
    ui.on_request_diff_delta({
    [2.1740]
    [2.1771]
    ui.on_request_diff_summary({
  • edit in src/main.rs at line 144
    [3.2115]
    [5.1019]
    }
    });
    ui.on_request_diff_delta({
    let ui_handle = ui.as_weak();
    move |ch_name: SharedString| {
    let ch_name = ch_name.as_str();
    let ui = ui_handle.unwrap();
    let exe_path_string = ui.get_exe_path();
    let exe_path = Path::new(exe_path_string.as_str());
    let repo_path_string = ui.get_repo_path();
    let repo_path = Path::new(repo_path_string.as_str());
    let diff_output = cmds::diff_short(
    exe_path,
    repo_path,
    Some(ch_name).filter(|cn| !cn.is_empty()),
    );
    let file_changes = match diff_output {
    Ok(delta) => delta,
    Err(e) => {
    println!("{:?}", e);
    return;
    }
    };
    ui.set_count_files_changed(i32::try_from(file_changes.len()).unwrap_or(-1));
  • edit in src/cmds.rs at line 85
    [3.2563]
    [9.1342]
    }
    pub fn diff_short(
    exe: &std::path::Path,
    repo: &std::path::Path,
    ch_name_maybe: Option<&str>,
    ) -> Result<serde_json::Map<String, serde_json::Value>, Error> {
    let mut cmd = Command::new(exe);
    let cmd = cmd
    .arg("diff")
    .arg("--no-prompt")
    .arg("--repository")
    .arg(repo)
    .arg("--short")
    .arg("--json");
    if let Some(ch_name) = ch_name_maybe {
    cmd.arg("--channel").arg(ch_name);
    }
    let output = cmd.output()?;
    check_exit_status(cmd, output.status)?;
    // TODO this will fail when diffing binary data
    Ok(serde_json::from_slice(&output.stdout)?)