gerrit: use "self" keyword for mine/todo lists
GoB has changed where looking up non-existent accounts in queries throws
an error. Since we only expand account names automatically to deal with
unlinked accounts, and we can't always assume that devs use the same name
with @chromium.org and @google.com, replace the logic with "self".
For people with linked accounts, this "just" works all the time, and no
longer yields CLs written by other devs (if they happen to have username
conflicts across domains). For people with unlinked accounts, this will
no longer show CLs posted by their other accounts. Since there is not a
good answer for that scenario, and there are few devs that applies to,
require them to use manual queries instead if they want everything.
BUG=chromium:680692
TEST=`gerrit mine` and `gerrit -i todo` still work (for me)
Change-Id: Ib4f99d0fabe0cbdba2791f428a8e5d124018ae73
Reviewed-on: https://chromium-review.googlesource.com/428018
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index b180aed..6147ae4 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -158,16 +158,8 @@
def _MyUserInfo():
- email = git.GetProjectUserEmail(constants.CHROMITE_DIR)
- [username, _, domain] = email.partition('@')
- if domain in ('google.com', 'chromium.org'):
- emails = ['%s@%s' % (username, domain)
- for domain in ('google.com', 'chromium.org')]
- else:
- emails = [email]
- reviewers = ['reviewer:%s' % x for x in emails]
- owners = ['owner:%s' % x for x in emails]
- return emails, reviewers, owners
+ """Try to return e-mail addresses used by the active user."""
+ return [git.GetProjectUserEmail(constants.CHROMITE_DIR)]
def _Query(opts, query, raw=True):
@@ -187,6 +179,7 @@
"""Query gerrit and filter/clean up the results"""
ret = []
+ logging.debug('Running query: %s', query)
for cl in _Query(opts, query, raw=True):
# Gerrit likes to return a stats record too.
if not 'project' in cl:
@@ -231,9 +224,8 @@
def UserActTodo(opts):
"""List CLs needing your review"""
- emails, reviewers, owners = _MyUserInfo()
- cls = FilteredQuery(opts, ('( %s ) status:open NOT ( %s )' %
- (' OR '.join(reviewers), ' OR '.join(owners))))
+ emails = _MyUserInfo()
+ cls = FilteredQuery(opts, 'reviewer:self status:open NOT owner:self')
cls = [x for x in cls if not IsApprover(x, emails)]
lims = limits(cls)
for cl in cls:
@@ -250,12 +242,11 @@
def UserActMine(opts):
"""List your CLs with review statuses"""
- _, _, owners = _MyUserInfo()
if opts.draft:
rule = 'is:draft'
else:
rule = 'status:new'
- UserActSearch(opts, '( %s ) %s' % (' OR '.join(owners), rule))
+ UserActSearch(opts, 'owner:self %s' % (rule,))
def _BreadthFirstSearch(to_visit, children, visited_key=lambda x: x):