浏览代码

[gerrit_util] Add auth parameter to GetAccountDetails

We need to use this to determine if an account exists to determine
what auth to use, so we have to be able to override the default auth
detection.

Bug: b/366261039
Change-Id: I814b47ac1518170846ff9a7e5dc210f26db3e985
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5869049
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
Allen Li 11 月之前
父节点
当前提交
b32c4f1abc
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      gerrit_util.py

+ 7 - 2
gerrit_util.py

@@ -1778,7 +1778,10 @@ def GetProjectHead(host, project):
     return ReadHttpJsonResponse(conn, accept_statuses=[200])
 
 
-def GetAccountDetails(host, account_id='self'):
+def GetAccountDetails(host,
+                      account_id='self',
+                      *,
+                      authenticator: Optional[_Authenticator] = None):
     """Returns details of the account.
 
     If account_id is not given, uses magic value 'self' which corresponds to
@@ -1789,7 +1792,9 @@ def GetAccountDetails(host, account_id='self'):
 
     Returns None if account is not found (i.e., Gerrit returned 404).
     """
-    conn = CreateHttpConn(host, '/accounts/%s' % account_id)
+    conn = CreateHttpConn(host,
+                          '/accounts/%s' % account_id,
+                          authenticator=authenticator)
     return ReadHttpJsonResponse(conn, accept_statuses=[200, 404])