Detect uploadvalidator error message
If git push refs/for/ errors out, inspect stdout message to detect
uploadvalidator rejection. If present, present user a solution.
R=ajp@google.com
Change-Id: I70aee7615f3d905127a31bd5679968ade75c234a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2888475
Reviewed-by: Andy Perelson <ajp@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
diff --git a/git_cl.py b/git_cl.py
index 55ff1e0..0ae2cd3 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2232,6 +2232,17 @@
push_stdout = push_stdout.decode('utf-8', 'replace')
except subprocess2.CalledProcessError as e:
push_returncode = e.returncode
+ if 'blocked keyword' in str(e.stdout):
+ raise GitPushError(
+ 'Failed to create a change, very likely due to blocked keyword. '
+ 'Please examine output above for the reason of the failure.\n'
+ 'If this is a false positive, you can try to bypass blocked '
+ 'keyword by using push option '
+ '-o uploadvalidator~skip, e.g.:\n'
+ 'git cl upload -o uploadvalidator~skip\n\n'
+ 'If git-cl is not working correctly, file a bug under the '
+ 'Infra>SDK component.')
+
raise GitPushError(
'Failed to create a change. Please examine output above for the '
'reason of the failure.\n'