presubmit_support for Gerrit: don't ignore 404.
Before, presubmit_support would fail with not very useful stacktrace if
Gerrit returns 404, which is usually due to missing/invalid credentials.
This CL fixes that and improves the exception message, and also improves
logic in git_cl.
R=agable@chromium.org
BUG=
Change-Id: Iae8f0c24422c46af70929c7d5d71993164887511
Reviewed-on: https://chromium-review.googlesource.com/409650
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
diff --git a/gerrit_util.py b/gerrit_util.py
index 4798e94..6ea57f5 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -475,12 +475,13 @@
return ReadHttpJsonResponse(CreateHttpConn(host, path))
-def GetChangeDetail(host, change, o_params=None):
+def GetChangeDetail(host, change, o_params=None, ignore_404=True):
"""Query a gerrit server for extended information about a single change."""
+ # TODO(tandrii): cahnge ignore_404 to False by default.
path = 'changes/%s/detail' % change
if o_params:
path += '?%s' % '&'.join(['o=%s' % p for p in o_params])
- return ReadHttpJsonResponse(CreateHttpConn(host, path))
+ return ReadHttpJsonResponse(CreateHttpConn(host, path), ignore_404=ignore_404)
def GetChangeCommit(host, change, revision='current'):