diff options
author | Jordan R Abrahams <ajordanr@google.com> | 2022-01-12 00:31:47 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-13 04:02:42 +0000 |
commit | c5b1bd6c4bb4f3e753c25872b58f1b9a53f3165b (patch) | |
tree | 27e990f96097b3eb7b38e0b6a51b90219054abce /llvm_tools | |
parent | 6683e0e6b2152e8e92e7da9c4008913518e1fbd8 (diff) | |
download | toolchain-utils-c5b1bd6c4bb4f3e753c25872b58f1b9a53f3165b.tar.gz |
patch_sync: Add better command debugging
This commit allows the git commands to print out
what the command was that they failed at. This
is pretty helpful in debugging what went wrong.
We don't capture the repo output ever, so that
can remained piped to the terminal. But we
need to do some trickery for the git cmd.
BUG=b:209493133
TEST=None
Change-Id: I389257fef1e3bf394fb4013588df6c78e83b733a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3379478
Reviewed-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Michael Benfield <mbenfield@google.com>
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
Diffstat (limited to 'llvm_tools')
-rw-r--r-- | llvm_tools/patch_sync/src/version_control.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm_tools/patch_sync/src/version_control.rs b/llvm_tools/patch_sync/src/version_control.rs index 3dc5aae9..3621a909 100644 --- a/llvm_tools/patch_sync/src/version_control.rs +++ b/llvm_tools/patch_sync/src/version_control.rs @@ -179,9 +179,16 @@ where I: IntoIterator<Item = S>, S: AsRef<OsStr>, { - let output = Command::new("git").current_dir(&pwd).args(args).output()?; + let mut command = Command::new("git"); + command.current_dir(&pwd).args(args); + let output = command.output()?; if !output.status.success() { - bail!("git command failed") + bail!( + "git command failed:\n {:?}\nstdout --\n{}\nstderr --\n{}", + command, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr), + ); } Ok(output) } @@ -191,9 +198,11 @@ where I: IntoIterator<Item = S>, S: AsRef<OsStr>, { - let status = Command::new("repo").current_dir(&pwd).args(args).status()?; + let mut command = Command::new("repo"); + command.current_dir(&pwd).args(args); + let status = command.status()?; if !status.success() { - bail!("repo command failed") + bail!("repo command failed:\n {:?} \n", command) } Ok(()) } |