Skip to content

Commit 7a03a16

Browse files
committed
Include standard out/error output in exception output
The pre-commit hook context would only include output from standard error when an exception occurred. Unfortunately, this sometimes leaves out important information for debugging purposes. Include both streams in the output to aid in debugging. Change-Id: Ib38348174c983d7133721120c64af6cba8f0254e Reviewed-on: http://gerrit.causes.com/42177 Tested-by: jenkins <jenkins@causes.com> Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
1 parent 6c676a7 commit 7a03a16

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
contained decimals
1111
* Warn when trying to pipe commands using the `execute` helper, as this is not
1212
supported
13+
* Include both standard out/error streams in exception messages in pre-commit
14+
hook context
1315

1416
## 0.16.0
1517

lib/overcommit/hook_context/pre_commit.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setup_environment
2828
# issue (e.g. author/email not set or GPG signing key incorrect)
2929
raise Overcommit::Exceptions::HookSetupFailed,
3030
"Unable to setup environment for #{hook_script_name} hook run:" \
31-
"\n#{result.stderr}"
31+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
3232
end
3333

3434
@changes_stashed = true
@@ -75,7 +75,7 @@ def clear_working_tree
7575
unless result.success?
7676
raise Overcommit::Exceptions::HookCleanupFailed,
7777
"Unable to cleanup working tree after #{hook_script_name} hooks run:" \
78-
"\n#{result.stderr}"
78+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
7979
end
8080
end
8181

@@ -85,7 +85,7 @@ def restore_working_tree
8585
unless result.success?
8686
raise Overcommit::Exceptions::HookCleanupFailed,
8787
"Unable to restore working tree after #{hook_script_name} hooks run:" \
88-
"\n#{result.stderr}"
88+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
8989
end
9090
end
9191

0 commit comments

Comments
 (0)