diff options
author | Mike Frysinger <vapier@google.com> | 2017-09-15 10:23:21 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-09-15 10:23:21 +0000 |
commit | d3758b6a752ef121a4a613a193e353c50cf20252 (patch) | |
tree | d47d6e02b140d067ffde3d3a472696ea30088343 | |
parent | f465fdc73f85eda7f98fbdb1ad349ea56ad8cd21 (diff) | |
parent | ee12b72f62ef9cb2a6881155e94bac3aa259b781 (diff) | |
download | repohooks-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-x | tools/clang-format.py | 10 |
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. |