diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-03-28 04:28:21 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-03-28 04:28:21 +0000 |
| commit | ea6ebde0ca303de0ad28e09191d263dc0be3f2c9 (patch) | |
| tree | a48d5a7fce8d2691e67a3c9fd05c71f2ed08fc89 | |
| parent | 73316598e68edb52962b70014e9057423d0f05e9 (diff) | |
| parent | e5ad9af086a78e289585f4c7c9905d59ea71617a (diff) | |
| download | platform_tools_repohooks-ea6ebde0ca303de0ad28e09191d263dc0be3f2c9.tar.gz platform_tools_repohooks-ea6ebde0ca303de0ad28e09191d263dc0be3f2c9.tar.bz2 platform_tools_repohooks-ea6ebde0ca303de0ad28e09191d263dc0be3f2c9.zip | |
Merge "pre-upload: fix handling of silent tools"
| -rwxr-xr-x | pre-upload.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/pre-upload.py b/pre-upload.py index 53b5ffb..467e6c8 100755 --- a/pre-upload.py +++ b/pre-upload.py @@ -173,6 +173,11 @@ def _process_hook_results(results): if not results: return (None, None) + # We track these as dedicated fields in case a hook doesn't output anything. + # We want to treat silent non-zero exits as failures too. + has_error = False + has_warning = False + error_ret = '' warning_ret = '' for result in results: @@ -183,11 +188,14 @@ def _process_hook_results(results): lines = result.error.splitlines() ret += '\n'.join(' %s' % (x,) for x in lines) if result.is_warning(): + has_warning = True warning_ret += ret else: + has_error = True error_ret += ret - return (error_ret or None, warning_ret or None) + return (error_ret if has_error else None, + warning_ret if has_warning else None) def _get_project_config(): @@ -307,10 +315,10 @@ def _run_project_hooks_in_cwd(project_name, proj_dir, output, commit_list=None): output.hook_start(name) hook_results = hook(project, commit, desc, diff) (error, warning) = _process_hook_results(hook_results) - if error or warning: - if warning: + if error is not None or warning is not None: + if warning is not None: output.hook_warning(name, warning) - if error: + if error is not None: ret = False output.hook_error(name, error) for result in hook_results: |
