From cff07523da7ba25c81821ecf31d11851c10ff6b9 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 10 Oct 2023 23:39:55 +0900 Subject: [PATCH] codegen: Tweak git_ls_files --- tools/codegen/src/file.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/codegen/src/file.rs b/tools/codegen/src/file.rs index fee31bc..d904396 100644 --- a/tools/codegen/src/file.rs +++ b/tools/codegen/src/file.rs @@ -149,14 +149,16 @@ pub fn write_raw(function_name: &str, path: &Path, contents: impl AsRef<[u8]>) - } pub fn git_ls_files(dir: &Path, filters: &[&str]) -> Result> { - let output = Command::new("git") - .arg("ls-files") - .args(filters) - .current_dir(dir) - .output() - .with_context(|| format!("failed to run `git ls-files {filters:?}`"))?; + let mut cmd = Command::new("git"); + cmd.arg("ls-files").args(filters).current_dir(dir); + let output = cmd.output().with_context(|| format!("could not execute process `{cmd:?}`"))?; if !output.status.success() { - bail!("failed to run `git ls-files {filters:?}`"); + bail!( + "process didn't exit successfully: `{cmd:?}`:\n\nSTDOUT:\n{0}\n{1}\n{0}\n\nSTDERR:\n{0}\n{2}\n{0}\n", + "-".repeat(60), + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr), + ); } Ok(str::from_utf8(&output.stdout)? .lines()