
This moves spawning of the git subprocess to the main thread. We're not yet sure why, but when we spawn a process using GCD's background queues, sub-processes like git-credential-manager fail to open windows. This seems to be fixable either by using the main thread, or by using a standard background thread, but for now we use the main thread. Release Notes: - Git: Fix git-credential-manager --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
use crate::Oid;
|
|
use anyhow::{anyhow, Result};
|
|
use collections::HashMap;
|
|
use std::path::Path;
|
|
|
|
pub async fn get_messages(working_directory: &Path, shas: &[Oid]) -> Result<HashMap<Oid, String>> {
|
|
if shas.is_empty() {
|
|
return Ok(HashMap::default());
|
|
}
|
|
|
|
const MARKER: &str = "<MARKER>";
|
|
|
|
let output = util::command::new_smol_command("git")
|
|
.current_dir(working_directory)
|
|
.arg("show")
|
|
.arg("-s")
|
|
.arg(format!("--format=%B{}", MARKER))
|
|
.args(shas.iter().map(ToString::to_string))
|
|
.output()
|
|
.await
|
|
.map_err(|e| anyhow!("Failed to start git blame process: {}", e))?;
|
|
|
|
anyhow::ensure!(
|
|
output.status.success(),
|
|
"'git show' failed with error {:?}",
|
|
output.status
|
|
);
|
|
|
|
Ok(shas
|
|
.iter()
|
|
.cloned()
|
|
.zip(
|
|
String::from_utf8_lossy(&output.stdout)
|
|
.trim()
|
|
.split_terminator(MARKER)
|
|
.map(|str| str.trim().replace("<", "<").replace(">", ">")),
|
|
)
|
|
.collect::<HashMap<Oid, String>>())
|
|
}
|