aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2017-09-15 10:23:21 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-09-15 10:23:21 +0000
commitd3758b6a752ef121a4a613a193e353c50cf20252 (patch)
treed47d6e02b140d067ffde3d3a472696ea30088343
parentf465fdc73f85eda7f98fbdb1ad349ea56ad8cd21 (diff)
parentee12b72f62ef9cb2a6881155e94bac3aa259b781 (diff)
downloadrepohooks-d3758b6a752ef121a4a613a193e353c50cf20252.tar.gz
clang-format: fail gracefully when clang-format itself aborts am: f363ab9d13 am: 23e637629c am: 71d3de9a45
am: ee12b72f62 Change-Id: I54fd05b21e5301cbbdb777afa69d133175b43c7b
-rwxr-xr-xtools/clang-format.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/clang-format.py b/tools/clang-format.py
index ac9e826..998eb49 100755
--- a/tools/clang-format.py
+++ b/tools/clang-format.py
@@ -78,7 +78,15 @@ def main(argv):
cmd.extend(['%s^' % opts.commit, opts.commit])
cmd.extend(['--'] + opts.files)
- stdout = rh.utils.run_command(cmd, capture_output=True).output
+ # Fail gracefully if clang-format itself aborts/fails.
+ try:
+ result = rh.utils.run_command(cmd, capture_output=True)
+ except rh.utils.RunCommandError as e:
+ print('clang-format failed:\n%s' % (e,), file=sys.stderr)
+ print('\nPlease report this to the clang team.', file=sys.stderr)
+ return 1
+
+ stdout = result.output
if stdout.rstrip('\n') == 'no modified files to format':
# This is always printed when only files that clang-format does not
# understand were modified.