Prevent command prompt from opening when running git blame on windows (#10747)

Release Notes:

- Fixed issue reported in discord where the git blame feature would open
command prompt windows
This commit is contained in:
Jason Wen 2024-04-18 16:02:24 -07:00 committed by GitHub
parent d4922eb10b
commit dd7eced2b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 4 deletions

View file

@ -4,15 +4,25 @@ use collections::HashMap;
use std::path::Path;
use std::process::Command;
#[cfg(windows)]
use std::os::windows::process::CommandExt;
pub fn get_messages(working_directory: &Path, shas: &[Oid]) -> Result<HashMap<Oid, String>> {
const MARKER: &'static str = "<MARKER>";
let output = Command::new("git")
let mut command = Command::new("git");
command
.current_dir(working_directory)
.arg("show")
.arg("-s")
.arg(format!("--format=%B{}", MARKER))
.args(shas.iter().map(ToString::to_string))
.args(shas.iter().map(ToString::to_string));
#[cfg(windows)]
command.creation_flags(windows::Win32::System::Threading::CREATE_NO_WINDOW.0);
let output = command
.output()
.map_err(|e| anyhow!("Failed to start git blame process: {}", e))?;