3W2E3DX2QDACZBU6VPPBRFO6OUUMEPTGH2BEANQFDH6OWRLXI4FAC
BD456SZFVRW32OG6PN2TN5R3SAGMVH64KW7HQA7LHAVXMIA4HIJAC
NSE6BLWA372T3TYEVMOKWWD725NRYQNLJGWEVXAIQ3EP6R2YNQ7QC
F6YAQWVDXG6UZBJPJDTIJBQDBMXVMT7P6INK6GPJ5SR3BDDRX4EQC
I4NM4O3Z7SDWAMQODOCPKJXL2LBMVUPQVGYQUXO6J7MW7WZAH5NAC
XERTHGSY3OMO7CBVVHIXI7LH6JY4AOS7BA6WQP22JBO2NDWGBH4QC
NCRTU7M46QRJ4VHTNJQ6OFHCGX5M2GGTUY2J5UW3RWEQSAYOGVPAC
4RPYR65C4IEKV3INJ67NN4DOH37UDY45EE7VGF55ZKDFH75LXLJAC
}
});
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));
}
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)?)